views:

49

answers:

2

Hello, i have Ruby class:

class Migrator

       def self.migrate_old_categories
        ActiveRecord::Base.establish_connection(:data_center_v2)
        ActiveRecord::Base.table_name = "categories"
      end

end

I need use it, as i used it always. For example: Category.find(:all) So, how i can it, when i'm write: Migrator.migrate_old_categories, end script find all Categories?

Thanx, apoligize for my english. Russian.

A: 

you can create some model just before your migration

class Category < AR
end

class Categories < AR
  def table_name
    "categories"
  end
end

After you can do

Category.all

and

Categories.all
shingara
Yes, i know. But in this class i need to use many models.In this class i have 8 methods with different models.I need create model in current method.
sesharim
A: 
class Category  < ActiveRecord::Base
def self.table_name() "categories" end
end
Ramanavel