I am just starting with Ruby on Rails. I bought “The Rails Way” by
Obie F. and just finished reading the first chapter, but there’s
something I didn’t quite understand: how so set the desired mode
(RAILS_ENV). The author says that it can be set in environment.rb by
uncommenting
ENV['RAILS_ENV"=‘production’]
but seems to discourage setting it here. Maybe I didn’t understand
what I read correctly, but is there an alternate, more reccomendable way
of setting the mode for a RoR app, or is this line the solution? Thanks
for any info.
how so set the desired mode
(RAILS_ENV). The author says that it can be set in environment.rb by
uncommenting
ENV['RAILS_ENV"=‘production’]
A rails application can be configured to use 3 environemnts in
normal case and additionally we can set more. They are Development,Test
and Production. As the name implies your development happens in env
development ,etc… Please check the development.rb ,test.rb and
production.rb in config/environments. In each of them we can set the
things needed for the corresponding environmnet. Open
config/environment.rb Here you can set the database connectivity
details.Each environment(development,test,production) can be connected
to corresonding db at run time. For example to start your application
say ‘your_app’ in test mode (with your_app_test db defined in
environment.rb) do
I am just starting with Ruby on Rails. I bought “The Rails Way” by
Obie F. and just finished reading the first chapter, but there’s
something I didn’t quite understand: how so set the desired mode
(RAILS_ENV). The author says that it can be set in environment.rb by
uncommenting
ENV['RAILS_ENV"=‘production’]
but seems to discourage setting it here. Maybe I didn’t understand
what I read correctly, but is there an alternate, more reccomendable way
of setting the mode for a RoR app, or is this line the solution? Thanks
for any info.
Ideally, you’re supposed to set the Rails environment from outside the
app, using the environment variable RAILS_ENV.
Ideally, you’re supposed to set the Rails environment from outside the
app, using the environment variable RAILS_ENV.
What happens if you’re running more than one rails app on a machine? How
do you handle that?
Environment variables can be separate for each process.
So you mean:
ENV_RAILS=“production” script/server
ACCEPT_KEYWORDS=“~x86” emerge gcc
Yes.
… That kind of thing? Or is there another way?
You can set environment vars in lots of ways. All are equivalent.
Since each process has its own environment, and since that environment
starts out as a copy of that of the parent process, you could even do
$ RAILS_ENV=development
$ cd app1
$ script/server -d -p 3000
$ RAILS_ENV=production
$ cd app2
$ script/server -d -p 3001
…though I don’t recommend it.
But if you’re not sure how to set environment variables, then please ask
in a basic Unix forum, not here. It’s really not a Rails issue.