As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

Rails Data Migrations are fucking me up

LegionnairedLegionnaired Registered User regular
edited March 2008 in Help / Advice Forum
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?

Legionnaired on

Posts

  • Options
    LegionnairedLegionnaired Registered User regular
    edited March 2008
    I managed to fix it using raw sql and the execute command... But anyone have a clue what my problem was in the first place?

    Legionnaired on
Sign In or Register to comment.