i would like to use different database for mailboxer tables. i have a user model that acts_as_messageable but then all the mailboxer models connect to my production schema. what i have tried is using delegated model user_ex that connect to second database and set this model to acts_as_messageable but only this model connect to the secont database and all other mailboxer models connected to the production.
the code:
user.rb
class User < ActiveRecord::Base
has_one :user_ex
end
messageable_base.rb
class MessageableBase < ActiveRecord::Base
establish_connection :DB_2
self.abstract_class = true
acts_as_messageable
end
user_ex.rb
class UserEx < MessageableBase
self.table_name = 'users'
belongs_to :user
end
Aucun commentaire:
Enregistrer un commentaire