個人的には、HABTM を削除します。代わりに私は使用しますhas_many :though=>
account_users と account_billers という 2 つの新しいモデルを作成する必要があります。HABTM の結合テーブルが既にある可能性がありますが、これによりそれらがモデルとして公開されるため、ID フィールドが必要になります。
したがって、次のような結果になります。
class Account < ActiveRecord::Base
has_many :account_billers
has_many :account_users
has_many :billers, :through=> :account_billers
has_many :users, :through=> :account_users
end
class User < ActiveRecord::Base
has_many :account_users
has_many :accounts, :through=>:account_users
validates :accounts, :length => { :minimum => 1}
end
class Biller < ActiveRecord::Base
has_many :account_billers
has_many :accounts, :through=>:account_billers
validates :accounts, :length => { :minimum => 1}
end
class AccountUser < ActiveRecord::Base
belongs_to :user
belongs_to :account
end
class AccountBiller < ActiveRecord::Base
belongs_to :biller
belongs_to :account
end