1

I'm learning ruby on rails by following the tutorials in http://ruby.railstutorial.org/ .

I'm getting invalid option error when I try to create a new project as below,

user1@ubuntu:~/rails_projects$ rails new sample_app -T
**invalid option: -T**

I don't find -T option in rails man page as well.

user1@ubuntu:~/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.
user1@ubuntu:~/rails_projects$ rvm notes

any thoughts why it's not available.

Thanks for your help.

Here is ruby & rails installation details,

user1@ubuntu:~/rails_projects$ rails -v
Rails 2.3.5
user1@ubuntu:~/rails_projects$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
user1@ubuntu:~/rails_projects$ 
Thi
  • 2,297
  • 7
  • 26
  • 36
  • What did it do in the previous Rails versions? – Michael Koper May 29 '11 at 16:46
  • What is the version of Rails you are using? Type `rails -v` and add that information to your question. The command you typed works fine in Rails 3.0.7. – Zabba May 29 '11 at 18:05
  • Also, it seems you are using rvm? In that case you are probably using the wrong ruby and/or rails gems (note that in the options listed `Default: /usr/bin/ruby1.8` is being shown for ruby. If you were using rvm that path would have been `/home//.rvm/rubies/....`) – Zabba May 29 '11 at 18:08
  • @Michael Koper & Zabba - I've updated installation details. – Thi May 29 '11 at 19:08

1 Answers1

2

Apparently you are using an old version of rails (possibly 2.x) but using the Rails 3.x syntax for creating an app. Note the example in your question:

Example:
    rails ~/Code/Ruby/weblog

So, omit the "new" and type rails sample_app. This is the command for creating apps in older versions (< 3.x) of rails.

In the Rails 3.x, the way to create a new app is by using "new" : rails new sample_app

You should ideally be using the latest stable rails (v 3.0.x) in which case you will also have the -T option available.

To setup your system correctly using 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

Note: Don't type the # and the stuff after it.. it's just there to show you what the command will do.

Zabba
  • 64,285
  • 47
  • 179
  • 207
  • Thank you. I realized I was using rails 2.x.x and I reinstalled rails 3.0.7 again and it's working fine. But I do have question here. I've installed both the Rails 2.x.x and 3.0.7 as well yesterday and was using rails 3.0.7 version by default. But today it's took rails 2.x.x version. Is there any way I can set to use 3.0.7 version rails like how we set for ruby? – Thi May 29 '11 at 19:28
  • Look at using gemsets. [See my answer here](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) for how to do that. – Zabba May 29 '11 at 19:34