Using Rails 3. In my project directory am trying to launch rails script/console by using "rails console" command line & get this in return.
Loading test environment (Rails 3.2.1)
irb(main):001:0>
1 Answer
I think you may be confused about the rails commands.
rails server (or script/server when using Rails 2.x) is used to start a web server for local development (this by default is Webrick running on 0.0.0.0:3000). This process runs in the foreground and does not allow for interaction. It will log output to STDOUT.
rails console (or script/console when using Rails 2.x) is used to start the interactive ruby shell (irb) with your Rails app and environment (development by default, test in your case) loaded. This is an interactive shell meaning that you can type ruby code in here and it will be executed when you hit the return key or when it encounters the end of a block. Try this out
a = ["b", "a", "r","t"]
a.reverse
Will return
=> ["t", "r", "a", "b"]
Since this also loads your Rails application, you have access to the classes defined in your application. For example, if you have a Person model defined, you can instantiate a new instance by typing the following into irb
Person.new
To leave the irb, you can type exit to return to your operating system's shell. I hope this helps to clear up some of the confusion.
rails consolebut when I run it I getLoading test environment (Rails 3.2.1) irb(main):001:0>with no return of command prompt.