I had a case where table was comming from database other then the one mentioned in database.yml
To do that in the model:
class EmUser < ActiveRecord::Base
set_table_name "OtherDatabase..User"
end
Where OtherDatabase is the database name which will different from your config file ( or sybase’s interfase) and user is the table name you want to use.
BUT BE VERY CAREFULL WITH THAT since as soon as you do that it will be kind of out of you testing database ( or whatever case may be) in order to overcome that I did the following:
def self.table_name_based_on_env
if RAILS_ENV 'development' or RAILS_ENV ‘production’
set_table_name “OTHER_DB..table_name”
elsif RAILS_ENV == ‘test’
set_table_name “table_name”
end
end
table_name_based_on_env
Ruby will execute table_name_based_on_env while setting up environment thus executing the table name based on RAILS_ENV