Rails 4 - Mapping a model dynamically on two different database tables -
i have multi domain app talking legacy database. in db have 2 tables different names, lets call them user_a , user_b . structure , data types same, difference data different domains. now, have single scaffold (model/controller/view) that, depending on domain, maps right db table. domain work model/controller called user maps internally db table user_a , , domain b work same model/controller user maps table user_b . i use resource :user in routes access model rails way. so somehow need overwrite model on initialization not quite sure how go it. how 1 go using rails activerecord? i don't have multitable db ready test with, educated guess @ solution: # respective models class user < activerecord::base end class domainauser < user self.table_name = "user_a" end class domainbuser < user self.table_name = "user_b" end # controller def set_user @user = if request.subdomain(0) == "domaina" domainaus...