Hi group, I have a line of code in environment.rb that cannot be run during a rake db:migrate, as it depends on some tables being present. I need to find a way to enclose this line in a check for db:migrate. I know how to check if we''re in a rake task with: unless defined?(Rake) # do stuff, but skip when run from rake tasks end How can I take this further to make check if I''m running the rake db:migrate task? Thanks, -H --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Excuse me, the code I need to wrap around the check is on ApplicationController. Still, any ideas? On Feb 5, 3:33 pm, Harold <harold.gime...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi group, > > I have a line of code in environment.rb that cannot be run during a > rake db:migrate, as it depends on some tables being present. > > I need to find a way to enclose this line in a check for db:migrate. I > know how to check if we''re in a rake task with: > > unless defined?(Rake) > # do stuff, but skip when run from rake tasks > end > > How can I take this further to make check if I''m running the rake > db:migrate task? > > Thanks, > > -H--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
There is a model class method like table_exists? That you can use to check ifthe table exists and then only run the code if it does On 06/02/2009, at 6:51, Harold <harold.gimenez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Excuse me, the code I need to wrap around the check is on > ApplicationController. Still, any ideas? > > On Feb 5, 3:33 pm, Harold <harold.gime...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi group, >> >> I have a line of code in environment.rb that cannot be run during a >> rake db:migrate, as it depends on some tables being present. >> >> I need to find a way to enclose this line in a check for >> db:migrate. I >> know how to check if we''re in a rake task with: >> >> unless defined?(Rake) >> # do stuff, but skip when run from rake tasks >> end >> >> How can I take this further to make check if I''m running the rake >> db:migrate task? >> >> Thanks, >> >> -H > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks! That would work, for now. I still have the itch though. If anyone knows, do tell. Thanks again, -H On Thu, Feb 5, 2009 at 4:22 PM, Ryan Bigg <radarlistener-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > There is a model class method like table_exists? That you can use to > check ifthe table exists and then only run the code if it does > > > > On 06/02/2009, at 6:51, Harold <harold.gimenez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Excuse me, the code I need to wrap around the check is on > > ApplicationController. Still, any ideas? > > > > On Feb 5, 3:33 pm, Harold <harold.gime...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi group, > >> > >> I have a line of code in environment.rb that cannot be run during a > >> rake db:migrate, as it depends on some tables being present. > >> > >> I need to find a way to enclose this line in a check for > >> db:migrate. I > >> know how to check if we''re in a rake task with: > >> > >> unless defined?(Rake) > >> # do stuff, but skip when run from rake tasks > >> end > >> > >> How can I take this further to make check if I''m running the rake > >> db:migrate task? > >> > >> Thanks, > >> > >> -H > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---