I have a relationship definition in my model definition, campaign.rb
that references another model, campaign_memberships.rb, that isn't
created until a later migration.
I have a relationship definition in my model definition, campaign.rb
that references another model, campaign_memberships.rb, that isn't
created until a later migration.
If the problem is really the order (but I'm not convinced it is, see below),
change the order of the migration, so that campaign_memberships happens
first. Assuming these are in the "db/migrate" directory, the way to do this
is to name them like:
001campaign_memberships.rb
002campaign.rb
If you use the "scripts/generate migration" command to create your
migrations, the order should be sorted out for you naturally.
Also, you shouldn't need to reference any actual model object here... the
migrations should really be thought of as a lower level than that. You could
make the "conditions' an actual SQL statement like
:conditions =>
"campaign_memberships.campain_membership_status_id = " +
"(SELECT id FROM campaign_membership_status WHERE code = 'resigned')"