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 there puts ''I am in migration mode'' end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ESPNDev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-20 22:16 UTC
Re: How do I ask Rails? environment.rb and initializers
yeah, but it''s RAILS_ENV On Mar 20, 6:49 am, Feurio <govinda.pfis...-enoGyz2oHxeELgA04lAiVw@public.gmane.org> wrote:> 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 > there > puts ''I am in migration mode'' > end--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? Feurio On 20 Mrz., 23:16, "ESPN...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <ESPN3.DL- Community...-xX8xgfAcNKEAvxtiuMwx3w@public.gmane.org> wrote:> yeah, but it''s RAILS_ENV > > On Mar 20, 6:49 am, Feurio <govinda.pfis...-enoGyz2oHxeELgA04lAiVw@public.gmane.org> wrote: > > > 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 > > there > > puts ''I am in migration mode'' > > end--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---