Anand
Anand

Reputation: 10400

How to Change the environment of a rails application?

Once I start coding a rails app, I am by default in development mode.

What should I do to change my rails environment to test or production mode ?

can I work in multiple environments simultaneously ?

Upvotes: 2

Views: 4157

Answers (3)

Salil
Salil

Reputation: 47482

to run application on production mode type in console

ruby script/server -e production

TO RUN SAME APPLICATION ON DIFFERENT ENVIORMENT you have to use different ports

like

ruby script/server -e production -p 3001

AND

ruby script/server -p 3002

Upvotes: 2

John Topley
John Topley

Reputation: 115362

It depends how you are running the application. When you run your tests then they automatically use the test environment. If you are using script/server (e,g, using WEBrick, Mongrel etc.) then you can pass the name of the environment to use on the command line e.g. script/server -e production.

  • If you are using Phusion Passenger then the environment can be specified using the RailsEnv configuration directive

  • If you are using the Rails console then specify the environment name directly: script/console production

  • You can create your own environments too. This Railscast has the details

Upvotes: 1

ohho
ohho

Reputation: 51941

script/server -e production for production mode

more in script/server --help

Upvotes: 0

Related Questions