在终端中输入Rails命令,返回帮助



当我输入:

$ rails server

我得到这个返回并输入rails命令:

Usage:
  rails new APP_PATH [options]
Options:
  [--edge]                   # Setup the application with Gemfile pointing to Rails repository
  [--dev]                    # Setup the application with Gemfile pointing to your Rails checkout
  -G, [--skip-git]               # Skip Git ignores and keeps
  -m, [--template=TEMPLATE]      # Path to an application template (can be a filesystem path or URL)
  -b, [--builder=BUILDER]        # Path to a application builder (can be a filesystem path or URL)
      [--old-style-hash]         # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
      [--skip-gemfile]           # Don't create a Gemfile
  -d, [--database=DATABASE]      # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                 # Default: sqlite3
  -O, [--skip-active-record]     # Skip Active Record files
      [--skip-bundle]            # Don't run bundle install
  -T, [--skip-test-unit]         # Skip Test::Unit files
  -S, [--skip-sprockets]         # Skip Sprockets files
  -j, [--javascript=JAVASCRIPT]  # Preconfigure for selected JavaScript library
                                 # Default: jquery
  -J, [--skip-javascript]        # Skip JavaScript files
  -r, [--ruby=PATH]              # Path to the Ruby binary of your choice
                                 # Default: /usr/bin/ruby1.8
Runtime options:
  -s, [--skip]     # Skip files that already exist
  -f, [--force]    # Overwrite files that already exist
  -p, [--pretend]  # Run but do not make any changes
  -q, [--quiet]    # Supress status output
Rails options:
  -h, [--help]     # Show this help message and quit
  -v, [--version]  # Show Rails version number and quit
Description:
    The 'rails new' command creates a new Rails application with a default
    directory structure and configuration at the path you specify.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.

为什么不启动服务器?对我来说,这似乎是一个rails帮助文档或类似的东西。类似的情况也发生在:

$ rails generate

我能做些什么来让这些命令正常启动吗?

我使用的是Rails 3.1.3版本,在Ubuntu上。

BTW:我从myapp的目录内输入这些,即

chuckles@.......:~/Blog/new$

我通过运行:

让服务器启动
$ script/server
从/新/

我有这个问题。原来我创建了一个与我的应用程序一起使用的gemset,然后当我切换到终端中的app文件夹时,它恢复到不支持我的应用程序的默认gemset。

你可以通过

检查你使用的是哪个gemset
rvm gemset list

所以在我的app文件夹中,我使用。

切换到合适的gemset
rvm gemset use [your gemset name]
然后

bundle install

更新gem文件

之后一切都很好。

如果你有'script/server',那么你可能有rails 2。X应用程序,而不是3.x。确保(rails -v)运行rails 3.x。X . X .

编辑:

我可能不够清楚。从你提供的信息中我看到:

  • 你有rails 3。它会显示帮助屏幕,因为它找不到Rails 3。li>你有一个由rails 2生成的应用程序。x gem(您有script/server脚本,您可以通过查看config/environment.rb文件来验证您的应用程序是否适用于较旧的rails)

这个组合不起作用。你得做点什么。如果您需要这个旧的应用程序,那么您可以卸载rails 3。X gem并安装2。x版。如果您可以将此应用程序迁移到使用捆绑器运行就更好了(这样您就不需要卸载rails 3了)。X gem),但如果不可能,您可以查看rvm的gemsets。

当我需要启动旧的应用程序时我该怎么做:

  1. rvm use ree -如果我的应用程序在服务器上使用Ruby企业版,否则rvm use [ruby version here],取决于哪个版本
  2. rvm gemset create [application name here] -使gemset特定于此应用
  3. rvm alias create [application name here] ree@[gemset name here] -以确保我可以回到这个宝石快速
  4. rvm use [alias name here] -切换到应用红宝石宝石组合
  5. 安装应用程序所需的所有gem(询问其他开发人员应该使用哪个版本以及如何安装它们)

然后当我回到开发这个应用程序时:

  1. rvm use [alias name here]
  2. ./script/server -启动应用程序

你还需要寻找Rails 2的教程和文档。

您只能在现有的rails项目文件夹中运行这些命令。查看输出的底部,它给出了一个示例命令来创建rails项目的框架结构。

或者,运行本教程http://guides.rubyonrails.org/getting_started.html

您需要在rails项目目录中才能运行这些命令。首先,创建一个新项目:

rails new myapp

,然后你可以进入它并运行服务器或其他命令。

cd myapp
rails server

检查您在rails应用程序根目录中的bin目录,我已经删除了它,它对我造成了问题。至少创建一个bin目录并复制这些文件。

bundle rails rake

最新更新