Uninitialized constant error in Rails migration
UPDATE:
This was because I had pluralized Tiers in its class definition, not because Rails was acting different. The below is not true, but it still is a good idea because if you change any models in the future, it will break subsequent migrations (which would likely happen anyways)
Now for some reason you have to define your models within your migration to get access to their functionality. It's not guaranteed that the migration will have automatic access to your models.
E.g.
This was because I had pluralized Tiers in its class definition, not because Rails was acting different. The below is not true, but it still is a good idea because if you change any models in the future, it will break subsequent migrations (which would likely happen anyways)
Now for some reason you have to define your models within your migration to get access to their functionality. It's not guaranteed that the migration will have automatic access to your models.
E.g.
class LoadTiersUsers < ActiveRecord::Migration extend MigrationHelpers class Tier < ActiveRecord::Base; has_and_belongs_to_many :users end class User < ActiveRecord::Base; has_and_belongs_to_many :tiers end class TiersUsers < ActiveRecord::Base; end def self.up p "*** Loading user, tier data..."