I am trying out multiple databases in Rails 4.0 in an app i'm making. Based on this: Connecting Rails 3.1 with Multiple Databases and http://api.rubyonrails.org/classes/ActiveRecord/Base.html
I was able to create the some models that use different connections, however, when I try to inherit the connection from an abstract class to keep my code DRY, Rails 4.0 automatically assumes that I'm trying to do Single Table Inheritance when I'm querying info and then throws a Mysql::Error that the table doesn't exist.
Here are some code snippets to shed some light on my current state Base Class:
Class Mps < ActiveRecord::Base
self.abstract_class = true
establish_connection "mps"
end
Child Class:
Class TblAdmVsl < Mps
self.table_name = "tbladmvsl"
end
Is there any way around this as I want to keep my code as DRY as possible. Below is the error I received when i tried this in the rails console
2.0.0-p247 :005 > TblAdmVsl.first
TblAdmVsl Load (4.5ms) SELECT `tbladmvsl`.* FROM `tbladmvsl` ORDER BY `tbladmvsl`.`id` ASC LIMIT 1
Mysql::Error: Table 'mps2_tbl.mps' doesn't exist: SHOW FULL FIELDS FROM `mps`
ActiveRecord::StatementInvalid: Mysql::Error: Table 'mps2_tbl.mps' doesn't exist: SHOW FULL FIELDS FROM `mps`
from /home/maru/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:286:in `query'
from /home/maru/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:286:in `block in execute'