15

Forgive me as I'm new to both *nix and ruby on rails. My rails command always creates a new application and I can't figure out why. Running "rails new myApp" will just generate a new rails application named "new" in the current directory. Likewise "rails server" just creates a new application in a folder named "server". Any ideas? I'm using Ubuntu 11.04 and rails 3.0.9.

John W
  • 1,472
  • 1
  • 14
  • 19

6 Answers6

25

For creating project in current directory, you can run:

rails new .
Viktor Oleksyn
  • 624
  • 7
  • 6
9

You have installed rails through apt-get so you have rails 2. If you want rails 3, use

sudo apt-get remove --purge rails # very important so that the new rails is called
sudo apt-get install rubygems
sudo gem install rails

Don't forget to relaunch your terminal and you're done.

Benoît Legat
  • 958
  • 1
  • 8
  • 10
5

When you create your application with rails new myApp, there should be a myApp/script directory and in there will be a script named rails, this is the rails that understands server and console. So, do this:

$ rails new MyApp
$ cd MyApp
$ script/rails server

To create and start up your application. The naming is a little confusing.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
  • @user359796: And if you use Rails 2, there will be several scripts (`server`, `console`, ...) in the `scripts/` directory instead of just `rails`. – mu is too short Jun 19 '11 at 06:53
  • 2
    This doesn't add up. If `rails new myApp` created a new Rails application named `new`, then the OP is on Rails 2, *not* Rails 3. – David Jun 19 '11 at 18:28
  • 1
    @David: Sounds to me like he has PATH confusion on top of everything else but maybe he figured out that part on his own. That's why I added the comment about Rails 2. Your point is a good one though. – mu is too short Jun 19 '11 at 18:40
  • This was very common for rails 3 users following rails 2 instructions. Getting a new app called 'new' is exactly the result of the mix-up due to the syntax change. – Michael Durrant Apr 15 '13 at 01:02
3

That sounds like the behavior of Rails 2, not Rails 3. With Rails 2, typing rails appname would create a new Rails application named appname. With Rails 3, the syntax is now rails new appname. You should double-check that you're using the version of Rails that you think you are. To do that, type rails --version.

David
  • 2,311
  • 1
  • 15
  • 13
2

The common way to create a Rails application is:

rails new MyApp

This will create a folder with your new Rails application called MyApp

If your folder name is the same name you plan to use for your application you can use the command below:

rails new .

Notice the period at the end telling it to use the current directory.

If you want to supply a specific application name, you’ll have to do the following:

rails new /path/to/folder/you/want/to/use

Stefan Ciprian Hotoleanu
  • 2,202
  • 1
  • 23
  • 30
1

Rails 2.3.5

rails new       # will create a project new 
rails new myapp # still will create a project new
rails server    # will create a project server

to run the server : cd script ( a directory in your project folder ) and then run ./server

farnoy
  • 7,356
  • 2
  • 20
  • 30
Leili
  • 11
  • 1