On Friday, August 12, 2016 at 5:27:07 AM UTC-7, Petr Kaleta wrote:
>
> Hello, I am using sequel_postgresql_triggers gem, to create counter 
> caches. That works great, but I need to prevent its overwriting when 
> updating its model. Currently I was using pretty simple approach that I 
> removed counter cache attributes from values in before_save hook. But after 
> its saving you can't access them any more. So the only was is to store them 
> in local variables and then once again populate it in after_save hook.
>
> Is there any better solution? Like some plugin etc?
>

I think using around_save might work best for this:

def around_save
  cache_value = values.delete[:cache_column]
  super
ensure
  values[:cache_column] = cache_value
end

Thanks,
Jeremy

-- 
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.

Reply via email to