2013-04-10 51 views
1

我有一個rails項目,我想添加一個新表,並且還在項目中已經存在的一個表中進行更改。 從終端和現有軌道項目的文件夾裏面我寫這篇文章:我無法在rails中生成模型或遷移

Mini-1:arbinet anna$ rails generate model PriceRate profitable_routes_id:int normalized_rate:float normalized_payout:float margin:float old_rate:float old_payout:float old_margin:float 

而且也是本作的遷移:

Mini-1:arbinet anna$ rails generate migration ChangeColumnsFromProfitableRoutes 

但不管我得到這個消息:

Usage: 
    rails new APP_PATH [options] 

Options: 
    -r, [--ruby=PATH]    # Path to the Ruby binary of your choice 
           # Default: /Users/anna/.rvm/rubies/ruby-1.9.3-p286/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. 

我不知道爲什麼,但它創建其他表時正在工作。

+0

http://guides.rubyonrails.org/command_line.html – 2013-04-10 09:30:19

回答

2

您應該從應用程序的適當docroot(文件夾)中調用'rails'命令。

所以,如果你的應用程序住在/pub/www/mycoolapp/你應該做的:cd /pub/www/mycoolapp/和運行軌道從那裏

+0

arbinet是我的應用程序的根文件夾 – Anna 2013-04-10 09:33:45

+0

當你輸入'rails console'時,你會得到什麼? – 2013-04-10 10:22:44

+0

相同的消息:用法: rails新APP_PATH [選項] .... – Anna 2013-04-10 10:29:21

2

一個小小彬後來命令,但也許這就是任何你可能有問題。

運行你的應用程序的根文件夾

bundle exec rake rails:update:bin 

,享受裏面的編碼命令!