Rails

Rails 6 introduces insert_all / upsert_all methods

Having methods that can perform database operations in bulk is always a plus considering the amount of efficiency they add to such operations. Rails already had methods like update_all and delete_all to bulk update and bulk delete records respectively. But, Ruby on Rails developers always felt a need for similar methods to bulk insert records. …

Rails 6 introduces insert_all / upsert_all methods Read More »

Rails before? after? methods to compare date / time

Before Rails 6.0, the date/time are compared by using the equality operators like less than (<) or greater than (>), etc. Sometimes, date/time comparison using these operators takes some time to understand as these conventions are not human-readable at least for dates. Now, Rails 6.0 active support introduced with two new methods before? & after? …

Rails before? after? methods to compare date / time Read More »

Rails 6 adds delete_by and destroy_by methods on ActiveRecord

Often we need to find records based on certain conditions and then delete those records. To perform this, ActiveRecord has introduced delete_by and destroy_by methods with Rails 6. Let’s say, we have a following model. Requirement: Delete all posts created by a user with ID 5. Before Rails 6 This can be done by using …

Rails 6 adds delete_by and destroy_by methods on ActiveRecord Read More »

Rails 6 ActiveSupport adds private option to delegated methods

Rails 6 is recently released with a lot of features. One of them is ActiveSupport adding support for private option on delegated methods to make delegated methods not accessible publicly. Before Rails 6 Before Rails 6, if we use delegate option for methods, it marks the delegated method publicly accessible. This could be undesirable at …

Rails 6 ActiveSupport adds private option to delegated methods Read More »

Rails 6 deprecates controller level force_ssl option

Previously, we were able to force_ssl to specific controller actions by using force_ssl callback at controller level. Rails 6 deprecates this option setting at controller level. This option to force_ssl is now available only at Rails application configuration level only. Before Rails 6 Let’s say, we have a resource configured for posts. The controller has …

Rails 6 deprecates controller level force_ssl option Read More »

Rails IP-Based access restriction with route constraints

Sometimes we need to limit access based on IP address and whitelist only certain IP addresses to access a route. We can use rails routing constraints to restrict an access. We can either whitelist or blacklist IP addresses for a route. Rails provides different basic constraints on routes like: HTTP Verb Constraints Segment Constraints Request-Based …

Rails IP-Based access restriction with route constraints Read More »

Heroku memory issue

How we dealt with R14 – Memory Quota Exceeded errors on Heroku

1 – Investigation to zero in on the real culprit We started observing resource utilization graphs for our dynos. As we all know that worker dynos carry most of the heavy lifting. They are indeed used to perform such tasks. So worker dynos are more prone to such errors than others. Then we started observing …

How we dealt with R14 – Memory Quota Exceeded errors on Heroku Read More »