Been refactoring my code today and indeed found a lot of places where I
could use that in combination with `find_or_create` or `update_or_create`,
which comes especially useful when you have something like:
campaign = Models::Campaign.update_or_create(find_cond) { ... }
MailCampaign.perform_
On Thu, Dec 30, 2021 at 12:51 PM tr...@upserver24.com
wrote:
> The use case is to know if current instance of the model was created, we
> pass model instance to many services which sometimes need to run additional
> actions if new record is just created, we can't have in after_create
> callback b
I've used something similar in the past for an API that had very specific
return codes, i.e. 201 if the resource was created and 200 or 204 if the
resource was updated.
I'm working on an app now that allows folks to subscribe to create and/or
update events, so I need to know whether a resource
The use case is to know if current instance of the model was created, we
pass model instance to many services which sometimes need to run additional
actions if new record is just created, we can't have in after_create
callback because model doesn't know about the services also sometimes it's
to
On Wed, Dec 29, 2021 at 8:47 AM tr...@upserver24.com
wrote:
> Hi,
>
> We found this tiny useful plugin that allows to detect if model instance
> was just created:
>
> ```
> module Sequel
> module Plugins
> module JustCreated
> module InstanceMethods
> def after_create
>
Hi,
We found this tiny useful plugin that allows to detect if model instance
was just created:
```
module Sequel
module Plugins
module JustCreated
module InstanceMethods
def after_create
@just_created = true
super
end
def just_created?