I am working on a project involving three models (recipient, award, announcer) and need to have a nested attributes when issuing an award by an announcer to multiple recipients. For an example, award form need to have the ability to do 3 things:
- Can add multiple-recipients (i.e. "add recipient", "remove recipient") - nested attributes
- After creating a new award, the award will be posted into recipient's profile.
- Enables future polling of @recipient.awards and @announcer.awards
Really struggle in terms of how to smartly solve this problem. The following data structure kind of made sense, however can not do "accepts_nested_attributes_for :recipients" in the award form. Can you help? Many thanks in advance.
class Recipient < ActiveRecord::Base
- has_many :awards
- has_many :announcers, :through => :awards
end
class Announcer < ActiveRecord::Base
- has_many :awards
- has_many :recipients, :through => :awards
end
class Award < ActiveRecord::Base
- belongs_to :announcer
- belongs_to :recipient
end