Well, the problem is that, since I'm making a gem that extends Refile with
Sequel, I don't know if users will call `save` or `save_changes/update` (if
it was only me, I would be ok with it). I would like that the thing works
when they do either. Especially I think they will use `update` in the
controller, since it combines `set` and `save` into a single command.

On Tue, Mar 17, 2015 at 4:02 PM Jeremy Evans <[email protected]> wrote:

> 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 a topic in the
> Google Groups "sequel-talk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sequel-talk/uSEoYlI8xfg/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

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

Reply via email to