2011-05-29 15 views
1

我正在學習在軌道上的紅寶石,遵循http://ruby.railstutorial.org/中的教程。在導軌中沒有-T選項新<app_name>命令

我收到無效選項錯誤,當我嘗試創建如下一個新的項目,

[email protected]:~/rails_projects$ rails new sample_app -T 
**invalid option: -T** 

我不覺得在軌手冊頁-T選項爲好。

[email protected]:~/rails_projects$ rails --help new 
Usage: /usr/share/rails-ruby1.8/railties/bin/rails /path/to/your/app [options] 

Options: 
    -r, --ruby=path     Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path). 
            Default: /usr/bin/ruby1.8 
    -d, --database=name    Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3/frontbase/ibm_db). 
            Default: sqlite3 
    -D, --with-dispatchers   Add CGI/FastCGI/mod_ruby dispatches code to generated application skeleton 
            Default: false 
     --freeze      Freeze Rails in vendor/rails from the gems generating the skeleton 
            Default: false 
    -m, --template=path    Use an application template that lives at path (can be a filesystem path or URL). 
            Default: (none) 

Rails Info: 
    -v, --version     Show the Rails version number and quit. 
    -h, --help      Show this help message and quit. 

General Options: 
    -p, --pretend     Run but do not make any changes. 
    -f, --force      Overwrite files that already exist. 
    -s, --skip      Skip files that already exist. 
    -q, --quiet      Suppress normal output. 
    -t, --backtrace     Debugging: show backtrace on errors. 
    -c, --svn      Modify files with subversion. (Note: svn must be in path) 
    -g, --git      Modify files with git. (Note: git must be in path) 

Description: 
    The 'rails' command creates a new Rails application with a default 
    directory structure and configuration at the path you specify. 

Example: 
    rails ~/Code/Ruby/weblog 

    This generates a skeletal Rails installation in ~/Code/Ruby/weblog. 
    See the README in the newly created application to get going. 
[email protected]:~/rails_projects$ rvm notes 

任何想法爲什麼它不可用。

感謝您的幫助。

這裏是紅寶石&導軌安裝的詳細信息,

[email protected]:~/rails_projects$ rails -v 
Rails 2.3.5 
[email protected]:~/rails_projects$ ruby -v 
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux] 
[email protected]:~/rails_projects$ 
+0

它在以前的Rails版本中做了什麼? – 2011-05-29 16:46:16

+0

您正在使用的Rails版本是什麼?輸入'rails -v'並將該信息添加到您的問題中。你輸入的命令在Rails 3.0.7中工作正常。 – Zabba 2011-05-29 18:05:52

+0

另外,它似乎你正在使用rvm?在這種情況下,你可能使用了錯誤的ruby和/或rails gem(注意,在列出的'Default:/ usr/bin/ruby​​1.8'中顯示的是ruby。如果你使用的是rvm, '/ home/ /.rvm/rubies/ ....') – Zabba 2011-05-29 18:08:26

回答

2

顯然,你使用的是舊版本的Rails(可能2.X),但使用了Rails 3.x的語法創建的應用程序。請注意,例如,在你的問題:

Example: 
    rails ~/Code/Ruby/weblog 

所以,省略了「新的」和式rails sample_app。這是用於在舊版本(< 3.x)中創建應用程序的命令。

在軌道3.x中,創建一個新的應用程序的方法是使用「新」:rails new sample_app

理論上,應該使用最新的穩定軌道(V 3.0.x的),在這種情況下,你會也有可用的-T選項。

要設置你的系統中正確使用RVM:

rvm install 1.8.7  #install Ruby 1.8.7 
rvm use 1.8.7 --default #always use 1.8.7 by default when you open a terminal 
ruby -v     #should show ruby 1.8.7 ..... 
gem install rails  #install the latest stable version of Rails 
rails -v    #should show Rails 3.something.something 
rails --help   #should show you the -T option now 

注意:不要鍵入#和之後的東西..它只是沒有告訴你什麼是該命令將執行。

+0

謝謝。我意識到我正在使用rails 2.x.x,並且我重新安裝了rails 3.0.7,它工作正常。但我在這裏有疑問。我昨天安裝了Rails 2.x.x和3.0.7,默認情況下使用rails 3.0.7版本。但今天它採用了rails 2.x.x版本。有沒有什麼辦法可以設置使用3.0.7版本的rails,比如我們如何設置ruby? – Thi 2011-05-29 19:28:24

+0

看看使用gemsets。 [在這裏看到我的答案](http://stackoverflow.com/questions/4601003/how-to-downgrade-from-ruby-1-9-2-to-ruby-1-8-7-to-run-rails -2-0-2/4601098#4601098)如何做到這一點。 – Zabba 2011-05-29 19:34:00

+0

非常感謝,這有所幫助。 – Thi 2011-05-29 20:58:14