Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

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.
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..."

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed