Xavier Snark wrote: > I am learning Rails and have run into a bit of difficulty with something > I suspect is not uncommon, but I'm having difficulty getting my point > across to Google. > [snip] > when I am creating a new event record > [snip]
I think you've minced some concepts here. http://guides.rubyonrails.org/association_basics.html#polymorphic-associations states that you can access the nested model through an instance that has a polymorphic association with another model, eg. "From an instance of the Employee model, you can retrieve a collection of pictures: @employee.pictures." Polymorphic associations give you the abilities that you're after, but not entirely. I believe that when you are creating and updating, you need to rely on NestedAttributes of the ActiveRecord model in order to use a single form for updating both the "subject" record and the related record. http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html I haven't successfully used this, but the documentation suggests that you must update your "subject" model with the 'accepts_nested_attributes_for :secondary' where :secondary is the nested model in order to manipulate the related record through the subject record's controller. This gives you the ability to modify the related record through values supplied in the request params hash. X -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.