Hey Fred

Thanks for the reply. So the scope of the State model definition in
each class is causing the problem. That makes sense... I'll try moving
them and see if that fixes the problem more cleanly.

I understand that running the migrations end to end isn't recommended
but the application is what it is and because the migrations were
written prior to seed.rb being introduced, there's quite a bit of data
manipulation going on in there leaving me no choice but to re-create
the database this way. Live and learn, eh.

N.

On Oct 23, 6:51 pm, Frederick Cheung <[email protected]>
wrote:
> > I don't what changed from Rails 2.1.2 and 2.3.4 to break these
> > migrations. If anyone's encountered this issue or can shed some light
> > on the problem it would give me some peace of mind.
>
> > I worked around the problem by dynamically creating and destroying
> > classes to access the state table each time I need them, but I'd much
> > rather understand the root cause of the problem and fix it if needed.
>
> The core issue is that the right way to do this is to do
>
> class SomeMigration < ActiveRecord::Migration
>   class State < ActiveRecord::Base
>   end
> end
>
> Like that each migration has its own copy of the class, no
> interfering. The big difference between 2.1.2 and later versions is
> probably that by default in production modes all classes are loaded up
> front, so in migrations 2 & 3 you are not creating a new state class -
> you're reopening the application's state class which could easily have
> validations, callbacks etc. and be confused by the fact that the
> columns aren't as expected. Last but not least, running all the
> migrations from the first to the last is not the reccomended way to
> deploy an app - you should be loading the schema file.
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to