Hi! I’m getting this strange migration error for this migration:
class CreateCustomers < ActiveRecord::Migration
def self.up
Customer.create :name => ‘TEST’, :zone_id => 0
end
def self.down
Customer.delete_all
end
end
Produces:
== CreateCustomers: migrating
– create({:name=>“TEST”, :zone_id=>0})
rake aborted!
undefined method `create’ for
#ActiveRecord::ConnectionAdapters::MysqlAdapter:0x46c2204
I “fixed” it by defining the customer model inside the migration. Why is
happening this? (the same kind of migrations are working for all my
models except “Customer”)
class CreateCustomers < ActiveRecord::Migration
class Customer < ActiveRecord::Base
end
def self.up
Customer.create :name => ‘TEST’, :zone_id => 0
end
def self.down
Customer.delete_all
end
end