【发布时间】:2018-08-24 16:37:20
【问题描述】:
我有下一个模型:
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。除此之外,这个问题的答案应该是必需的。
你能给我提供完成解决方案的任何方向吗?
【问题讨论】:
标签: ruby-on-rails accepts-nested-attributes