The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

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

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