I have a bunch of rake tasks that work against whichever database is associated with the current RAILS_ENV. But there is another rake task that I want to invoke those db neutral tasks from that should only ever work against the test database. How do I override RAILS_ENV before invoking the database neutral tasks? Thanks! -b -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You could do rake RAILS_ENV="test" taskname or are you looking for something more programmable? On 7/20/07, Bryan Wilkerson <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I have a bunch of rake tasks that work against whichever database is > associated with the current RAILS_ENV. But there is another rake task > that I want to invoke those db neutral tasks from that should only ever > work against the test database. > > How do I override RAILS_ENV before invoking the database neutral tasks? > > Thanks! > > -b > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Brian Hogan wrote:> You could do > > rake RAILS_ENV="test" taskname > > or are you looking for something more programmable?More programmable. I noticed in looking the standard Rails test tasks that they aren''t very DRY. There are a couple of places where code is repeated from the db namespace tasks apparently just to solve this problem. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bryan Wilkerson wrote:> I have a bunch of rake tasks that work against whichever database is > associated with the current RAILS_ENV. But there is another rake task > that I want to invoke those db neutral tasks from that should only ever > work against the test database. > > How do I override RAILS_ENV before invoking the database neutral tasks? > > Thanks! > > -bI take back what I said about the test tasks. One of them provided me with the answer - you have to just set the connection. ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[''test'']) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---