I have a database being hosted in development environment and production environment. I am writing an API which based on a parameter in request will write to table in either development or production DB. I have put both entries in by database.yml
file :
development:
adapter: mysql2
database: db1
username: root
password:
timeout: 5000
host: a.b.c.d
pool: 5
port: 1234
production:
adapter: mysql2
database: db1
username: root
password:
timeout: 5000
host: a.b.c.e
pool: 5
port: 1234
This is my active record :
class table1 < ActiveRecord::Base
self.table_name = 'table1'
end
How do i write to different environments based on a request parameter ?