[英]Nested attributes with acceptance radio buttons
我有下一個型號:
class Student < ApplicationRecord
has_many :special_offers_participants
end
class SpecialOffersParticipant < ApplicationRecord
belongs_to :special_offer
belongs_to :student
end
class SpecialOffer < ApplicationRecord
has_many :special_offers_participants
end
我需要為學生創建注冊表格,該表格將根據會話屬性具有接受特殊要約或拒絕單選按鈕(不是)(會話可以具有special_offer_id)。 對我來說,顯然要使用嵌套的表單屬性來完成此操作,但是表單應該有一個問題: Do you accept special offer
和單選按鈕: Yes/No
。 除此之外,還需要回答這個問題。
您能為我提供完成解決方案的任何指導嗎?
class Student < ApplicationRecord
has_many :offers
has_many :promotions, through: :offers
end
class Offer < ApplicationRecord
belongs_to :student
belongs_to :promotion
end
class Promotion < ApplicationRecord
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.