我正在研究Michael Hartl的Rails教程,在第3.4节“生成静态页面控制器”中,我无法执行'rails generate controller StaticPages home help'。当我键入命令时,我收到以下消息,该消息看起来像是rails帮助消息:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile] # Don't create a Gemfile
-B, [--skip-bundle] # Don't run bundle install
-G, [--skip-git] # Skip .gitignore file
[--skip-keeps] # Skip source control .keep files
-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
[--rc=RC] # Path to file containing extra configuration options for rails command
[--no-rc] # Skip loading of extra configuration options from .railsrc file
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 generate integration_test static_pages'只是为了看看会发生什么,并且它返回了相同的消息。不确定这是否意味着什么,但我想我会把它包括在内。
答案 0 :(得分:0)
当您在非rails项目的目录中运行rails命令(带有任何args)时,会生成该响应。您要么没有正确创建rails项目,要么没有进入项目。
尝试重新创建rails项目。
答案 1 :(得分:0)
如果在Mac或Linux上,请键入pwd
以获取当前工作目录。这是您预期的rails应用程序的目录吗?如果没有,请进入。
答案 2 :(得分:0)
首先,最新教程遵循Ruby 2.0和Rails 4.0 我不知道你为什么开始使用Rails 3,但即使你这样做,你也应该这样做:
你应该遵循这样的事情。
rails new myapp
(然后切换到myapp目录。)
rails generate controller Staticpages home help
(如果你不想自动生成测试文件,你可以在最后添加--with-no-test-framework)
让宝石工作
bundle install
休息已经存在,我希望你明白问题出在哪里