【发布时间】:2014-08-11 21:57:36
【问题描述】:
我正在尝试使用以下命令在我的 rails 应用程序中生成控制器:
rails generate controller CreditCard
但它只是返回以下内容:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /export/data0/home/tanya/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
-b, [--builder=BUILDER] # Path to a application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--skip-gemfile] # Don't create a Gemfile
[--skip-bundle] # Don't run bundle install
-G, [--skip-git] # Skip Git ignores and keeps
-O, [--skip-active-record] # Skip Active Record files
-S, [--skip-sprockets] # Skip Sprockets files
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository
-T, [--skip-test-unit] # Skip Test::Unit files
[--old-style-hash] # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Suppress status output
-s, [--skip] # Skip files that already exist
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.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
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 3.2.13 和 ruby 1.9.3。
非常感谢您的帮助。
【问题讨论】:
-
看起来您正在以
Rails 2或更低版本运行Rails 3命令。您确定您的Rails 版本是3.2.13? -
执行 'rails -v' 返回 Rails 3.2.13
-
好吧,在
Rails 2中运行你的命令会为我返回相同的message。 -
rails 命令行的版本不一定反映应用中安装的 rails 版本。要确保使用相同的版本,请尝试
bundle exec rails ...。使用bundle exec为您的命令添加前缀会指示捆绑程序使用与您的应用程序捆绑的 gem 版本。如果你这样做,你仍然会得到同样的行为吗?
标签: ruby-on-rails ruby-on-rails-3.2