2014-01-05 82 views
0

我正在通過Michael Hartl的Rails教程和第3.4節「生成StaticPages控制器」,我無法執行'rails generate controller StaticPages home help' 。當我鍵入命令,我收到以下消息看起來是一個軌道的幫助信息:Hartl Rails教程第3節'rails generate controller'

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. 

我也嘗試過「軌產生integration_test static_pages」只是爲了看看會發生什麼,以及它返回相同的消息。不知道這是否意味着什麼,但我想我會把它包括在這裏。

+0

你創建的Rails應用程序? – alex

+0

即使您的確是按照@alex的說法創建了應用程序,請檢查您是否確實在其中進行了「cd」操作(即檢查您是否在您的應用程序根目錄中)。 – zrl3dx

+0

是的,我創建了rails應用程序,並正在從sample_app目錄進行工作。 – user3163541

回答

0

當您在不是rails項目的目錄中運行rails命令(包含任何參數)時,會生成該響應。你要麼沒有正確創建rails項目,要麼你沒有cd到項目中。

嘗試重新創建rails項目。

0

如果在Mac或Linux上輸入pwd以獲取當前工作目錄。這是您預期的rails應用程序的目錄嗎?如果沒有,請進入它。

0

所有最新的教程首先是下面的Ruby 2.0和Rails 4.0 我不知道爲什麼你已經開始使用Rails 3,但即使你這樣做,你應該做的象下面這樣:

您應該遵循什麼喜歡這個。

  1. rails new myapp(然後切換到MYAPP目錄。)

  2. rails generate controller Staticpages home help

(你可以添加--with-沒有測試的框架,最後,如果你不希望一個測試文件自動生成)

寶石工作

  1. bundle install

休息已經在那裏,我希望你明白問題出在哪裏

相關問題