On Tuesday, March 17, 2015 at 5:36:49 AM UTC-7, Janko Marohnić wrote: > > Hello Jeremy, > > I'm trying to integrate Sequel with Refile > <https://github.com/refile/refile>. How it Refile integrates with a model > is similar to other uploading solutions, with callbacks/hooks. There is > already an ActiveRecord integration > <https://github.com/refile/refile/blob/master/lib/refile/attachment/active_record.rb>, > > and I'm trying to make Sequel's one similar. > > However, there is one key difference between ActiveRecord and Sequel when > triggering of hooks. ActiveRecord *always* saves the record (thus trigger > the before_save callback), even when no columns change. Sequel triggers the > before_save only when columns change (or it's a new record). Is it possible > to make Sequel always save? It would be great to have it as a per-model > setting. > > I'm currently doing it in a way that I'm overriding `avatar=`, > `remove_avatar=` and `avatar_remote_url=`, and calling `will_change_column` > to trigger the change (becuase on `before_save` the column does get > changed). But I don't like this approach, I have to tie too tightly to > Refile's implementation. >
Can't you just call save instead of save_changes/update? 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 http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
