So, I have "Tags" and "Bayes" models setup, and tables already added to database.
Now I'm trying to do a data migration to populate it. My code is as follows:
class PopulateTagsAndBayes < ActiveRecord::Migration
def self.up
require '/Users/bartlowa/Projects/Hero/db/migrate/lib/classifier'
[:brave, :creative, :driven, :patient, :friendly, :vulnerable, :flexible, :caring, :smart, :romantic, :humble, :sacrificial, :gallant, :leader, :inspiring, :loyal, :attractive, :destined, :wounded, :hurt, :passionate, :protector, :persevering, :mediator, :redeemer, :saint].each do |name|
Tag.create(:name => name,
:x => rand(1000),
:y => rand(1000)
)
end
newbayes = Classifier::Bayes.new
[:brave, :creative, :driven, :patient, :friendly, :vulnerable, :flexible, :caring, :smart, :romantic, :humble, :sacrificial, :gallant, :leader, :inspiring, :loyal, :attractive, :destined, :wounded, :hurt, :passionate, :protector, :persevering, :mediator, :redeemer].each do |name|
newbayes.add_category(name)
end
mydata = Marshal.dump(newbayes)
Bayes.create(:data => mydata,
:id => 1
)
end
def self.down
end
end
and I'm getting this when I try to run the migration:
rake aborted!
undefined method `create' for #<ActiveRecord::ConnectionAdapters::MysqlAdapter:0x3286ee8>
so what the fuck? Is it just not loading my model? How do I fix this?
Posts