Problem With Migrations

Hi, I'm following an example of a Rails Book (Practical JRuby on Rails
Projects, by Ola Bini) and I'm stuck with a weird exception.

I have these 3 migration files, but when I run them (with rake
db:migrate) I see the following exception:

rake aborted!
CreateProductCategories is not missing constant ProductType!

Does anybody knows why? I append the 3 migrations below.
Thanks!

Hi, I'm following an example of a Rails Book (Practical JRuby on Rails
Projects, by Ola Bini) and I'm stuck with a weird exception.

I have these 3 migration files, but when I run them (with rake
db:migrate) I see the following exception:

If you run them one at a time does it work ? (ie move migrations 2 and
3 out of the migrate folder for a minute, run db:migrate,move them
back again, run miograte again?)

Seems related to http://dev.rubyonrails.org/ticket/6272

in which case the problem is that the belongs_to :product_type is
looking for the wrong ProductType class. You might be able to guide it
on its way with class_name => 'CreateProductCategories::ProductType'

Fred

class_name => 'CreateProductCategories::ProductType' did the trick!!!

Thank you so much Frederick!!

I think this will work too

class ProductType < ActiveRecord::Base; end
class CreateProductTypes < ActiveRecord::Migration
...
def self.load_data
   ProductType.create :name => 'Book'
   ProductType.create :name => 'Music'
   ProductType.create :name => 'Movie'
end
...
end