On Feb 14, 3:27 pm, Jeremy Evans <[email protected]> wrote:
> On Feb 14, 3:21 pm, Josh Bassett <[email protected]> wrote:
>
> > I'm not really a fan of the idea for having to specify :_create in the 
> > attributes for each nested model. That would make this feature quite 
> > cumbersome to use. Also, I feel that would confuse things as you can 
> > currently create nested models (albeit without a specific PK) without any 
> > special :_create attribute.
>
> > How about, as you initially suggested, if it just requires you to call 
> > .unrestrict_primary_key in the parent model class?

Looking at the nested_attributes code, this might be a simpler
solution to this issue:

  class Artist
    def nested_attributes_update(reflection, pk, attributes)
      nested_attributes_create(reflection, attributes) unless super
    end
  end

By default, nested_attributes_update returns the object to be updated
if it exists, and nil otherwise.  So if the object doesn't exist, this
code will create it instead of doing nothing.  Can you try that and
let me know if it works?

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to