If the only time you're worried about your code failing is during the migration you can simply add a check to see if the table exists and if not don't execute the code. it's not a very clever solution but does the job.
On Oct 10, 4:03 pm, Brian Hartin <[EMAIL PROTECTED]> wrote: > I know that we shouldn't make database calls in the Initializer, but how > do we avoid this when a class 'bootstraps' itself when it is required, > e.g. > > class Status < ActiveRecord::Base > # Add constants representing the various status > SUBMITTED = self.find(...) > APPROVED = self.find(...) > DENIED = self.find(...) > end > > I have, in my initialization block, a line which causes some model > classes to be 'required', e.g. > > config.active_record.observers = :audit_observer # 'requires' observed > classes > > My problem is that the initialization block runs while executing > migrations, and therefore fails on a migration from version 0, because > the Status table doesn't yet exist. > > I've tried config.after_initialize, with no luck. Is there some other > way to do initialization only after the migrations have run? > > Thanks. > > Brian > -- > Posted viahttp://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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

