I have a database being hosted in development environment and production environment. I am writing a api which based on a parameter in request will write to table in either environment or production db. I have put both entries in by database.yaml file :
class table1 < ActiveRecord::Base
self.table_name = 'table1'
You could use two models for the same table, one connected to the production database and the other connected to the development database.
Lets say your connection parameters are in the variables
You would also have to adapt your code to know which model to use.
class table1 < ActiveRecord::Base establish_connection($production) self.table_name = 'table1' end class table1test < ActiveRecord::Base establish_connection($developent) self.table_name = 'table1' end