Created
June 20, 2012 09:35
-
-
Save jhjguxin/2959066 to your computer and use it in GitHub Desktop.
rails has_many through and Multiple databases causing SQLite::BusyException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
establish_connection "users_#{Rails.env}" # use alternate DB | |
has_many :memberships | |
has_many :groups, through => :memberships | |
end | |
class Group < ActiveRecord::Base | |
establish_connection "users_#{Rails.env}" # use alternate DB | |
has_many :memberships | |
has_many :users, :through => :memberships | |
end | |
class Membership < ActiveRecord::Base | |
belongs_to :group | |
belongs_to :user | |
# validations stuff | |
establish_connection "users_#{Rails.env}" # use alternate DB | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment