Matthew Stopa
Matthew Stopa

Reputation: 3865

Changing a Active Record DB in Rails

I have a rails app I created with based on a DB with a table named "countries", which stored a list of all the countries in the world. Now I have found out that the actual DB I will be using uses a table named "ctry" instead (stupid I know). What I am trying to figure out is if there is any way I can point active record to this new table without having to swap out every single instance in "countries" from the controller names, file names, etc.

I'm not at all sure if this could possibly be done with routes or how someone might do it.

This is the active record model as it exists now:

class countries < ActiveRecord::Base
end

Upvotes: 0

Views: 134

Answers (1)

klochner
klochner

Reputation: 8125


class Country < ActiveRecord::Base
    set_table_name "ctry"
end

http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002286

Upvotes: 4

Related Questions