I have a separate DB for one model in my application and in development mode the connection is working properly, in production however it isn't.
production:
adapter: mysql
host: myhost
username: root
password:
database: production_db
users_production:
adapter: mysql
host: myhost
username: root
password:
database: other_db
The model that connects to the other database is called User but the
table it references in other_db
is smf_users
so my User.rb looks like
this:
class User < ActiveRecord::Base
establish_connection "users_#{RAILS_ENV}"
set_table_name "smf_users"
end
In production I'm getting this error:
Mysql::Error: Table 'production_db. smf_users' doesn't exist:
Note how it is trying to connect to the wrong database and so isn't finding the correct table. As I say, this works in development mode.
Any suggestions?