I guess what I'm going for is something like this:
def self.update_or_create_with_id(attrs) id = attrs.delete(primary_key) record = block_given? ? yield(id) : self[id] record.update(attrs) if record # can return nil record || create(attrs) end On Thursday, March 2, 2017 at 1:50:07 AM UTC+2, Aryk Grosz wrote: > > Whenever I use this plugin, if I'm trying to check based on the primary > key, I get an error because it always tries to set the foreign key > attribute on the resulting record (whether it's being created or updated). > > Was this intentional behavior? If you have incoming attrs and want to > check for the primary key and pull the record based on that, does it have > to be done manually? Or is there something in the library that I'm missing? > > > > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
