は、基本的に我々は2つのモデルを持っていると私は本当に持っている意味は何台レールはhas_and_belongs_to_manyのバリエーションをサポートしていますか?
class Guests < ActiveRecord::Base
has_and_belongs_to_many :events
end
class Event < ActiveRecord::Base
has_and_belongs_to_many :guests
end
class CreateJoinTableGuestsEvents < ActiveRecord::Migration
def change
create_join_table :guests, :events do |t|
t.index [:guest_id, :event_id]
t.index [:event_id, :guest_id]
end
end
end
参加:それは結合テーブルを使用するため
class Guest < ActiveRecord::Base
has_one :event
end
class Event < ActiveRecord::Base
belongs_to :guests
end
が、それは可能ですか?