When coding in Ruby, we tend to make typo errors. This can take up time if not quickly identified. did_you_mean spellchecker gem helps detect such errors and also presents suggestions that can resolve typo errors.
To parse natural language datetime string in Ruby,
we can use gem
Chronic is a
date parser in Ruby.
This comes very handy,
if we want to parse natural language datetime input
from user to Time / DateTime classes.
Rails CompareWithRange core extension adds support
Range as an argument
to Range#===, Range#cover? and Range#includes? methods.
Ruby already has support for these three methods,
but ruby does not support Range value as an argument.
This change is targetted to release and deprecate
with Rails 6.1.
has been released recently.
method was introduced with the release.
This is equivalent to Random::DEFAULT.bytes.
The feature returns random bytes
the length argument passed to it.
Before action callback in Rails has support to add conditions like if and unless. The callback is executed only if the conditions evaluate to true. But, skip_before_action callback does not support conditionals. In this article we will learn how to skip certain action based on some condition.
Sometimes we need to parse a date string in UTC timezone in Ruby.
Time.parse considers system time zone whereas we might want to parse time in UTC or some other custom timzone. This article helps parse time in UTC or any other zone.
Rails ActiveSupport Enumerable
adds index_with method.
This method allows creating hash with
a value from block passed or default value.
This is useful when we want to create a hash
value needs to be generated with some custom logic.
Sometimes we need to have a request be processed in a particular timezone in Rails.
To set a timezone per request in Rails,
we can have an around filter that sets timezone,
runs the requests and then resets timezone to what it was before the request.
Rails redirects route not found requests to
Sometimes, we need to redirect to 404 not found page from a controller action.
This can be done by rendering 404.html page or raising
Setting Time.zone in a Rails application changes time zone globally.
Whenever Time.now is used in any other request,
it uses whatever Time.zone is set to earlier.
To avoid Time.zone issues, do not set Time.zone.
Instead, use in_time_zone method to get time in desired zone.
Before Rails 5.1, secrets management was a hassle.
Gems like dotenv-rails, sekrets were being used
manage secrets in Rails applications.
Rails 5.1 released secrets management feature based on sekrets gem.
This article will explain how to manage application secrets with Rails 5.1 applications.
Writing subqueries can be a tedious job,
when working with Rails ActiveRecord. Rails ActiveRecord can handle subqueries.
Subqueries can be written by passing ActiveRecord Relation in where clause.
This article discusses how to write subqueries with ActiveRecord in Rails.
Missing indexes on database tables causes performance issues.
gem helps finding out missing indexes on database table in Rails code.
lol_dba performs static analysis of the code to find out missing indexes.
We will take a look at how to use lol_dba to find out indexes.
lol_dba also helps creating a migration to add the requred indices.
Sometimes, we need to delete records logically but not physically. Paranoia gem allows us to soft delete records. Records are marked as deleted by a column in a table. Article helps understand how to soft delete Records in Rails with Paranoia gem.