イベント、ベンダー、および会場モデルがあります。
イベントには複数のベンダーを含めることができますが、会場は 1 つです。
会場には、複数のベンダーと複数のイベントを含めることができます。
ベンダーは、複数の会場と複数のイベントを持つことができます。
イベント テーブル、会場テーブル、ベンダー テーブル、events_vendor テーブル、events_venue テーブルがあります。
モデルをセットアップするにはどうすればよいですか?
class Event < ActiveRecord::Base
attr_accessible :name, :budget, :client, :date, :description, :attendees,
:assets_attributes, :tag_list
belongs_to :user
has_many :assets, :dependent => :destroy
has_many :vendors
has_one :venue
accepts_nested_attributes_for :assets, :allow_destroy => true
acts_as_taggable
end
class EventsVendors < ActiveRecord::Base
attr_accessible :event_id, :vendor_id
end
class EventsVenues < ActiveRecord::Base
attr_accessible :event_id, :venue_id
end
class Vendor < ActiveRecord::Base
attr_accessible :city, :contact, :country, :description, :email, :employees,
:latitude, :longitude, :minimum, :name, :state, :street, :tel, :type
belongs_to :event
end
class Venue < ActiveRecord::Base
attr_accessible :capacity, :city, :contact, :country, :email, :exclusiveVendors, :fee,
:latitude, :longitude, :name, :state, :street, :tel, :union
belongs_to :event
has_many :vendors
end
events_venues モデルはイベントと会場の両方に属していますか? :through 関係を指定する必要がありますか?
どんな助けでも大歓迎です。ありがとう!