Keshav Biswa

Keshav Biswa

Keshav is a Ruby on Rails Developer.
authorImg Keshav Biswa

Sort Your Rails Models By The Order of their Associations

Sort your Rails models by the order of their belongs_to associations using ActiveRecord::Reflection.
authorImg Keshav Biswa

Shaping Rails to Your Needs, Customizing Rails Generators using Thor Templates

Templates are an easy way to customize your Rails generators to fix repetitive tasks and make your life easier.
authorImg Keshav Biswa

Rails 7.1 Introduces Default Health Check Controller

Rails 7.1 now introduces a default health check endpoint for health checks.
authorImg Keshav Biswa

Rails initializers you don't know about - Inflections

Rails comes with a lot of initializers. In this post, we will look at the inflections.rb initializer and how we can use it.
authorImg Keshav Biswa

Rails 7.1 db:prepare to load schema if the database already exists but is empty

Rails 7.1 introduces a new feature to allow db:prepare to load schema if the database already exists but is empty. Also, it will dump the schema after migrations are run.
authorImg Keshav Biswa

Rails allow opting out of the SameSite cookie attribute when setting a cookie

Rails 7.1 introduces a new feature to allow opting out of the SameSite cookie attribute when setting a cookie.
authorImg Keshav Biswa

Rails "ActionController::Parameters.to_h" can now receive a block

ActionController::Parameters.to_h will now receive a block just like Hash#to_h and achieve parity. This gives the ability to customize the way parameters are passed to the controller.
authorImg Keshav Biswa

The Ultimate Guide to Gemfile and Gemfile.lock

In-depth overview of what a Gemfile is and how a Gemfile works.
authorImg Keshav Biswa

Rails adds --js alias to --javascript

Rails now provides support to choose a javascript approach using --js alias
authorImg Keshav Biswa

Rails now provides pattern matching support for ActiveModel

Rails now provides pattern matching support for ActiveModel (and transitively ActiveRecord)
authorImg Keshav Biswa

Rails 7 adds ActiveRecord::Relation#structurally_compatible?

Rails 7 adds ActiveRecord::Relation#structurally_compatible? to provide an easy way to check if two relations are structurally compatible before running `or` or `and` query on it.
authorImg Keshav Biswa

Rails 7 optimizes remove_columns to use a single SQL statement when supported

Rails 7 remove_columns will now trigger a single SQL statement to remove all columns if the database supports it, instead of querying multiple SQL statements for removing individual columns.
authorImg Keshav Biswa

Rails 7 allows loading nested locales in the engine

Rails 7 allows loading nested locales inside the `/locales` directory by default for better organization in larger apps.
authorImg Keshav Biswa

Rails 7 generators will raise errors if an attribute type is invalid

Rails 7 generators will validate the type by checking if it is of a default migration type and will raise an error if it is invalid.
authorImg Keshav Biswa

Ruby 3.1 adds Enumerable#compact and Enumerator::Lazy#compact

Ruby 3.1 adds Enumerable#compact and Enumerator::Lazy#compact to return a copy of `self` with all `nil` elements removed.
authorImg Keshav Biswa

Rails 7 adds maximum and minimum methods to Enumerable

Rails 7 adds `Enumerable#maximum` and `Enumerable#minimum` to calculate the maximum or minimum from extracted elements of an enumerable.