Awesome, I read the documentation about these two, but obviously not very carefully. Thank you!
On Mon, Jun 8, 2015 at 3:34 AM Jeremy Evans <[email protected]> wrote: > On Sunday, June 7, 2015 at 3:01:21 PM UTC-7, Janko Marohnić wrote: >> >> I was recently implementing a basic Elasticsearch integration with >> Sequel, and I wanted to save the record to Elasticsearch in an >> `after_commit` callback. However, inside it I don't know if a record has >> been destroyed, because in that case I need to remove it from the >> Elasticsearch index. >> >> I think it would be really useful to mark a record as destroyed with an >> instance variable @destroyed (just like with @new), and also add a >> `#destroyed?` method, just like ActiveRecord has. What do you think? >> > > I don't think it's necessary to have #destroyed in the base plugin. If > you want #destroyed, you can load the active_model plugin, which contains > it. > > In the base plugin, you can use #exists? to check to see if the record is > still in the database. > > However, for what you want to do, you don't need either. after_commit is > only called when saving the record, if you call Model#destroy, the > after_destroy_commit hook is called, not after_commit. > > 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/WD_IZJ_ld4I/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.
