How do I ask Rails? environment.rb and initializers

Can I ask rails somehow in environment.rb or in an initializer if it
runs via a

  • script/server
  • script/console
  • rake db:migrate
  • etc.

Maybe something like

if RAILS_MODE == ‘Migration’

don’t do a Category.find(1) because the category table might not be

puts ‘I am in migration mode’

yeah, but it’s RAILS_ENV

I don’t understand your answer.

RAILS_ENV is an environment variable I can set with either
development, test or production and Rails then behaves differently.
Even for migrations you can provide the target like

RAILS_ENV=production rake db:migrate

Maybe you could clarify what you meant?


On 20 Mrz., 23:16, “[email protected]” <ESPN3.DL-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs