This blog is part of our Rails 5 series.
Rails 5 added
method which is used
to prevent the receiver from being saved
during the given block.
Use case for suppress method
we have an E-commerce application,
which has many products.
Whenever new product is launched
then subscribed customers are notified about it.
This creates a notification record every time
we launch a product.
Now, we have a situation
where we need to launch a product
but we don’t want to send notifications
Before Rails 5, this was possible
only by adding more conditions.
ActiveRecord::Base.Suppress in Rails 5
In Rails 5, we can use
to suppress creating of notifications as
As we can see,
no new notifications were created when
product is launched inside
the pull request
to gain better understanding of how