Jay
Jay

Reputation: 6244

Can't find my error in accepts_nested_attributes_for syntax

In my Receipt model:

  attr_accessible ..., :donor_contacts_attributes
  has_many :donor_contacts
  accepts_nested_attributes_for :donor_contacts

In my DonorContact model:

  belongs_to :receipt

In my controller new action:

@receipt = Receipt.new
@donor_contact = DonorContact.new

The error that I get on save:

Can't mass-assign protected attributes: donor_contact

I don't see what I've done wrong. Any of you see it? Thanks for your help.

Upvotes: 0

Views: 40

Answers (1)

phron
phron

Reputation: 1845

In your Receipt model try to change

attr_accessible ..., :donor_contacts_attributes

by

attr_accessible ..., :donor_contact_attributes

Upvotes: 1

Related Questions