I have a typical has_many relationship between two models (let's say has_many Authors. Article)
My article form allows the user to:
- Create new authors and link them to an article,
- Select existing authors to link to.
- Remove association with the Author (without deleting the author’s entry.)
I am using accepts_nested_attributes_for, and this works fine with C # 1. However, I have not yet found a better way to implement # 2 and # 3, still using accepts_nested_attributes_for.
It actually worked for me with Rails 3.0.0. ActiveRecord will automatically create a new association if an identifier of an author that he had not previously seen is set. But it turned out that I accidentally used a security bug that was fixed in Rails 3.0.1.
I tried a bunch of different approaches, but nothing works completely, and I can not find much information about best practices in this case.
Any advice would be appreciated.
Thanks,
Russell.
source share