Prasanth Chaduvula

Prasanth Chaduvula

I'm a React, Javascript & Rails full-stack Software Engineer. I have been working remotely for the past two years in a remote village. Before joining as a Software Engineer I founded kwiq - a hyperlocal delivery startup to deliver things in remote villages.
authorImg Prasanth Chaduvula

Rails 8.1 introduced except_on option for validations and callbacks

To skip validations for particular contexts, Rails added `except_on` option for validations and callbacks.
authorImg Prasanth Chaduvula

Rails 8.1 update_all with joins Support

Rails 8.1 has improved Active Record functionality by enhancing the support for update_all with joins for Postgresql and SQLite.
authorImg Prasanth Chaduvula

Rails 8.1 now sorts table columns

Rails 8.1 sorts table columns by name when dumping schema, avoiding merge conflicts when two branches modify the same table concurrently.
authorImg Prasanth Chaduvula

Rails 8 Dev Container Without Redis

With Rails 8, applications use the Solid Queue and Solid Cache gems by default, so it do not include redis in the dev container.
authorImg Prasanth Chaduvula

Rails Self-Join UPDATE for Outer Joins

Rails no more generates the subqueries as it uses self-join for `UPDATE` with outer joins on PostgreSQL and SQLite.
authorImg Prasanth Chaduvula

Rails 8 adds built in authentication

Rails 8's built-in authentication generator offers a lightweight, secure alternative to Devise with full control.
authorImg Prasanth Chaduvula

Rails Stops Generating bin/bundle Binstub

In new Rails applications, the bin/bundle is no longer included by default, as managing the correct Bundler version is now handled directly by RubyGems.
authorImg Prasanth Chaduvula

Rails 8 Removes Default Channels Folder

With Rails 8, channels folder dropped from default app/ structure as Hotwire is default in Rails.
authorImg Prasanth Chaduvula

Rails ActiveModel Normalization

Rails brings attribute normalization to ActiveModel, allowing custom formatting rules for model attributes.
authorImg Prasanth Chaduvula

Rails Strong Parameters Deep Dive

Explore Rails Strong Parameters, their role in preventing mass assignment vulnerabilities, and how they enhance security and maintainability.
authorImg Prasanth Chaduvula

Rails 8 Script Folder and Generator

The new script folder to hold one-off or general purpose scripts, such as data migration scripts, cleanup scripts and a scripts generator.
authorImg Prasanth Chaduvula

Rails 8 ISO 8601 TimeWithZone#inspect

Rails 8 ensures TimeWithZone#inspect aligns with Ruby standards, ensuring time formatting consistency across the board by supporting ISO 8601 Style.
authorImg Prasanth Chaduvula

What Is New In Ruby 3.4: Key Features

Ruby 3.4 brings performance boosts with GC, YJIT, Prism parser, frozen_string_literal, and block parameters.
authorImg Prasanth Chaduvula

Rails 8 add_enum_value if_not_exists

Rails 8 introduces if_not_exists option on add_enum_value, we can now safely add a new enum value, preventing errors if the value already exists.
authorImg Prasanth Chaduvula

Rails 8 Parameters#expect Method

Learn how Rails 8's Parameters#expect enhances parameter handling to safely filter and require params, improving security and reducing application errors.
authorImg Prasanth Chaduvula

Rails 8 drop_table Accepts Array

Rails 8 allows dropping multiple tables in one call with drop_table by accepting an array of table names in a single migration.
authorImg Prasanth Chaduvula

Rails 8 Multiple Rate Limits Per Controller

Rails 8 introduces the ability to define multiple rate limits within a controller, offering better flexibility for traffic management.
authorImg Prasanth Chaduvula

Rails 7.2 explain Method Enhancements

With Rails 7.2, the object returned by explain now responds to pluck, first, last, average, count, maximum, minimum, and sum methods.
authorImg Prasanth Chaduvula

Rails 7.1 Counter Methods Accept By Arg

Rails 7.1 adds a `by` argument to increment_counter and decrement_counter, allowing updates by custom amounts instead of just 1.
authorImg Prasanth Chaduvula

Rails 7.1 application.deprecators Method

Rails 7.1 adds Rails.application.deprecators for fine-grained control over deprecation warnings, including debug mode and silencing.
authorImg Prasanth Chaduvula

Rails 7.1 Validators Accept Lambdas

With Rails 7.1, we can use lambdas without record argument with ActiveModel validators.
authorImg Prasanth Chaduvula

Rails 7.2 Job Scheduling in Transactions

In Rails 7.2, ActiveJob delays job enqueuing until the transaction is committed and drops the job if the transaction is rolled back.
authorImg Prasanth Chaduvula

Rails 7.1 Controller Generator --parent

With Rails 7.1, the controller generator now accepts the --parent option. This allows us to generate a controller that inherits from the specified parent class.
authorImg Prasanth Chaduvula

Rails 7.1 Array#intersect? for AR Relations

Rails 7.1 added Array#intersect? method which returns true if two ActiveRecord relation objects have at least one element in common, otherwise returns false.
authorImg Prasanth Chaduvula

Rails 7.1 Reserved Attribute Name Error

Rails 7.1 raises error when we generate model with reserved attribute names.
authorImg Prasanth Chaduvula

Rails 7.1 --unused Routes Option

With Rails 7.1, identify and manage unused routes declared in the application by using bin/rails routes --unused option.
authorImg Prasanth Chaduvula

Rails inverse_of in Associations

Explore the inverse_of option in Rails associations, highlighting its benefits in performance, data consistency, and optimizing bi-directional relationships.
authorImg Prasanth Chaduvula

Rails 7.1 exclude? and extract_value Methods

Rails 7.1 adds exclude?, returning true if a key is missing from parameters. And extract_value, which splits a parameter value by delimiter into an array.
authorImg Prasanth Chaduvula

Rails 7.1 in_batches Descending Order Fix

With Rails 7.1, in_batches method without a block works fine for both `ASC/DESC` order values.
authorImg Prasanth Chaduvula

Rails 7.1 after_discard for ActiveJob

Rails 7.1 introduces the after_discard method, allowing us to run a callback when a job is about to be discarded.
authorImg Prasanth Chaduvula

Rails 7.1 AR Transaction Instrumentation

With Rails 7.1, we can subscribe to ActiveRecord transaction events for instrumentation with the help of transaction.active_record.
authorImg Prasanth Chaduvula

Rails 7.1 Disallow Foreign Keys Option

With Rails 7.1, we can disable foreign key constraints for the entire application by adding foreign_keys false option to database.yml
authorImg Prasanth Chaduvula

Rails 7.1 Readonly Attribute Error

Rails 7.1 now raises an ActiveRecord::ReadonlyAttributeError on assignment to readonly attributes.
authorImg Prasanth Chaduvula

Rails 7.1 Multiple Mailer Preview Paths

Rails 7.1 adds support for multiple mailer preview paths, enhancing flexibility and organization by allowing previews across various directories.
authorImg Prasanth Chaduvula

Rails 7.1 Logs Job Enqueue Callers

Rails 7.1 ActiveJob logs background job enqueue callers with backtraces, showing the file and line number where jobs are triggered.
authorImg Prasanth Chaduvula

Rails Ignore Counter Cache on Backfill

With Rails 7.2, we can now ignore counter cache columns during backfilling, allowing faster execution by reducing N+1 queries from counter cache column updates.
authorImg Prasanth Chaduvula

Rails 7.1 Composite Key Batch Ordering

Rails 7.1 adds multi-column ordering support for composite primary keys in find_each, find_in_batches, and in_batches methods.
authorImg Prasanth Chaduvula

Rails 7.1 *_deliver Mailer Callbacks

With Rails 7.1, we can hook into the lifecycle of email delivery with the help of ActionMailer before_deliver, around_deliver and after_deliver callbacks.
authorImg Prasanth Chaduvula

Rails Warns On Tests Without Assertions.

With Rails 7.2, `ActiveSupport::TestCase` now warns when tests do not run any assertions.
authorImg Prasanth Chaduvula

Rails 7.2 Adds Support For Devcontainer.

In Rails 7.2, use `--devcontainer` flag with `rails new` to add a devcontainer to new apps and run `bin/rails devcontainer` for existing apps.
authorImg Prasanth Chaduvula

Functional Programming In React

Learn how React implements functional programming with immutable data, pure functions, and composition.
authorImg Prasanth Chaduvula

CSS Units Guide - rem, em, px, vh, vw Explained

Master CSS units like rem, em, px, vh, vw, and percentage. Learn when to use absolute vs relative units for responsive web design.
authorImg Prasanth Chaduvula

Controlled vs Uncontrolled Components in React

Learn the key differences between controlled and uncontrolled components in React and when to use each.
authorImg Prasanth Chaduvula

Rails SKIP_TEST_DATABASE_TRUNCATE Flag

Rails 7.2 adds SKIP_TEST_DATABASE_TRUNCATE flag to speed up multi-process test runs by skipping table truncations on large databases.
authorImg Prasanth Chaduvula

Puma-dev: Run Multiple Rails Apps Locally

Use puma-dev to run multiple Rails apps with custom .test domains and HTTPS locally.
authorImg Prasanth Chaduvula

Rails after_all_transactions_commit Callback

Rails 7.2 adds after_all_transactions_commit to safely run actions like job enqueuing only after all transactions are committed.
authorImg Prasanth Chaduvula

Rails with_connection for DB Optimization

Rails 7.2 adds with_connection to lease database connections only for a block's duration, improving concurrency for IO-heavy apps.
authorImg Prasanth Chaduvula

Ruby 3.4 Keyword Args in Index SyntaxError

Passing keyword arguments in index to an array set methods throws SyntaxError.
authorImg Prasanth Chaduvula

Rails 7.2 order Supports Hash Values

With Rails 7.2, ActiveRecord::Relation#order supports hash values where keys are table name, value is a hash of key (column name) and value (order direction).
authorImg Prasanth Chaduvula

Rails 7.2 PG Adapter Date Type Casting

Rails 7.2 adds a Date decoder to the PostgreSQL adapter to type cast date columns to Ruby Date.
authorImg Prasanth Chaduvula

Ruby 3.4 Block in Index SyntaxError

Passing a block as an argument in index to an array throws SyntaxError in Ruby 3.4 as it is no longer allowed.
authorImg Prasanth Chaduvula

Rails 7.2 n_plus_one_only Strict Loading

In Rails 7.2, with strict loading in :n_plus_one_only mode, associations are eagerly loaded and child associations are lazy loaded.
authorImg Prasanth Chaduvula

Ruby 3.4 Range#size TypeError Fix

Range#size raises TypeError if the begin value of Range is a Float or Rational or Beginless.
authorImg Prasanth Chaduvula

Ruby 3.4 **nil No Longer Raises TypeError

When double splat ** operator used with nil, it is treated similarly to **{}, which passes no keywords and does not call any conversion methods.
authorImg Prasanth Chaduvula

Rails validate_foreign_key for Data Integrity

validate_foreign_key validates foreign key constraint and is designed to reduce the impact of adding foreign keys on high-traffic tables in PostgreSQL.
authorImg Prasanth Chaduvula

Rails 7.2 GitHub CI Workflow by Default

All new applications using Rails 7.2 will have GitHub CI workflow by default.
authorImg Prasanth Chaduvula

Rails 7.1 explain Accepts Options

Adding analyze and verbose as ActiveRecord::Relation#explain options give us deeper insight into query performance.
authorImg Prasanth Chaduvula

Rails 7.1 ActiveRecord regroup Method

With regroup and regroup! methods we can override the group_values
authorImg Prasanth Chaduvula

Rails 7.1 allows resetting singular

Query database again to retrieve the associated record by resetting the cache on singular associations.
authorImg Prasanth Chaduvula

Rails 7.1 Disable Enum Auto-Methods

Disable auto generated methods of ActiveRecord.enum with instance_methods by passing false to it.
authorImg Prasanth Chaduvula

Rails 7.1 path_params for url_for

path_params allows specified params to be used exclusively for named segments under scoped routing without unnecessarily appending parameters to every URL.
authorImg Prasanth Chaduvula

Ruby 3.3 Range#reverse_each Improvements

Range#reverse_each can now process beginless ranges with an Integer endpoint and raises TypeError for endless ranges.
authorImg Prasanth Chaduvula

Fly Postgres Backup to S3 via GitHub Actions

Discover how GitHub Actions empowers automation to effortlessly backup Fly.io hosted postgres databases, saving backups to a designated S3 bucket.
authorImg Prasanth Chaduvula

Rails 7.1 reselect Accepts Hash Values

Use of hash syntax for specifying columns and aliases with the ActiveRecord::QueryMethods#reselect method makes it easier for querying.
authorImg Prasanth Chaduvula

Ruby 3.3 Introduces Range#overlap? method

Compare two ranges and see if they overlap each other. overlap? returns true if two ranges overlap each other, otherwise false.
authorImg Prasanth Chaduvula

Rails 7.1 Default Dockerfile for Production

Rails 7.1 generates Dockerfile, .dockerignore, and docker-entrypoint for easy production deployment.
authorImg Prasanth Chaduvula

Rails 7.1 perform_all_later for Jobs

perform_all_later allows us to enqueue multiple jobs that belong to different classes simultaneously within ActiveJob.
authorImg Prasanth Chaduvula

Rails 7.1 Async Query Support in ActiveRecord

With the Active Record API for general async queries we can efficiently query not so fast queries asynchronously to improve the performance.
authorImg Prasanth Chaduvula

Rails 7.1 generates_token_for Method

Generate tokens for specific purposes and verify their authenticity.
authorImg Prasanth Chaduvula

Rails 7.1 ActiveRecord Normalization

Rails 7.1 lets you define custom normalization rules for model attributes with the normalizes method.
authorImg Prasanth Chaduvula

Rails 7.1 Autoload Lib with Ignore Option

Autoloading lib directory isn't always straightforward. In this blog post, we'll delve into the autoloading of the lib directory using config.
authorImg Prasanth Chaduvula

Rails Object#with for Attribute Management

We can use Object#with method as shorthand for the common begin/ensure pattern to save the value of an attribute, setting a new value, and then restoring
authorImg Prasanth Chaduvula

React state management - useReducer vs Redux

This blog explores useReducer vs Redux, delving into their definitions, use cases, code samples and when to choose each for efficient state management.
authorImg Prasanth Chaduvula

Rails Object#in? Now Supports Open Ranges

We can use Object#in? method to check open date ranges i.e. beginless and endless ranges.
authorImg Prasanth Chaduvula

Speed Up Rails with CloudFront CDN

Learn how to integrate Amazon CloudFront CDN with your Rails app to serve static assets faster and reduce load times significantly.
authorImg Prasanth Chaduvula

When to extract code to React custom hooks?

React custom hooks help us to build reusable logic, and make the code more readable.
authorImg Prasanth Chaduvula

Rails Ignore Tables in Schema Dumps

Ignore tables by configuring regular expressions on ActiveRecord::SchemaDumper.
authorImg Prasanth Chaduvula

Rails Routes Prefixed with cable

Rails improved its support for routes which helps us to navigate to routes prefixed with word cable which were throwing 404 errors before.