Migration problem

Hi,

I seem to have a fundamental misunderstaning or Rake, Ruby, or
Migrations.(or perhaps all three)

I have done dozens of simple Migrations with just a self.up and
self.down… Now I have one that is more complex and I want to call
other methods within the migration… but it doesn’t work…
Here is my self.up:
def self.up
drop_old_tables
create_tables
populate_questions
populate_forms
end

here is the error message:
undefined method `drop_old_tables’ for
#ActiveRecord::ConnectionAdapters::MysqlAdapter:0x499deb0

I have a drop_old_tables method defined lower down.

Thanks in anticipation for any help

Giorgio

I figured it out myself!

All the methods must be class methods as there is no instance I
suppose.
ie self.drop_old_tables etc.

Cheers
Giorgio

Make sure the other methods are defined on the same class and as class
methods with “def self.x”

Michael

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs