Swaathi Kakarla

Swaathi Kakarla is a Ruby on Rails Developer.
Swaathi Kakarla

Rails optimizes ActiveRecord batching for whole table iterations

Response times for batch queries have significantly improved by moving to a range-based iteration strategy.
Swaathi Kakarla

Enumerable#many? now forwards all block parameters

When used in conjunction with each_with_index Enumerable#many? does not forward index parameter unlike Enumerable#any?.
Swaathi Kakarla

Rails serializes store data as a regular hash instead of using HWIA

Serializing store objects with ActiveSupport::HashWithIndifferentAccess is both a wasteful and an insecure option. Instead Rails now encodes store as a regular hash and casts it back to HWIA before accessing.
Swaathi Kakarla

Ruby adds a new core class called Data to represent simple immutable value objects

The Data class helps define simple classes for value-alike objects that can be extended with custom methods.
Swaathi Kakarla

Pending migrations now show path instead of filename

Rails warns users of pending migrations now by showing the path of the migration file, instead of just the name. This is useful in multi-db applications.
Swaathi Kakarla

Rails adds the --parent option to the job generator

Similar to the working of the model generator, the job generator now accepts the --parent option. This allows one to generate a job that inherits from the specified parent class.
Swaathi Kakarla

Rails 7 fixes timezone awareness for tsrange and tstzrange columns

Earlier the tsrange/tstzrange column would throw a TypeError if a timezone was set in the application config. This column now stores time with the correct timezone.
Swaathi Kakarla

Rails adds :strict option to the default SQLite database.yml file

SQLite can be configured to be strict to circumvent some of its quirks. Rails can now specify this in the default database.yml file.
Swaathi Kakarla

Rails now validates options used in migration functions

Previously erroneous options were silently ignored in migration functions such as "create_table" or "add_column", now they raise an error.
Swaathi Kakarla

Rails now allows specifying the HTTP status code in assert_redirected_to

The assertion statement previous was only able to assert that the request was redirected, but not the status code.
Swaathi Kakarla

Rails adds source attribute to its ErrorReporting API

Subscribers can now filter error reports based on source, making it easier to ignore internal errors or focus on specific errors.
Swaathi Kakarla

Rails raises exception when config.active_storage.service is not explicitly set

Developers are no longer presented vague errors when config.active_storage.service is not set. Instead a clear exception is raised.
Swaathi Kakarla

Rails now supports infinite range options in LengthValidators

Models that need to be validated for length can use infinite ranges in :in / :within options
Swaathi Kakarla

Rails no longer produces false-positive query cache hits when querying with mutable bound parameters

ActiveRecord now dups and freezes complex types when making query attributes which prevents false-positive query cache hits.
Swaathi Kakarla

Rails now allows EML files to be downloaded from the email preview

An option to download .eml files directly from the browser when using the email preview feature will now be available in Rails 7.0.
Swaathi Kakarla

Rails improves the "in_order_of" querying method

The query that previously only used to allow symbolic column names, now handles string values.
Swaathi Kakarla

Rails now uses error_highlight to locate the columns where an error is present

With the help of Ruby 3.1's error_highlight functionality, Rails can now pinpoint the exact column where an error is present.
Swaathi Kakarla

Rails 7 adds default value support for binary columns for SQLite

Binary columns now behave like other column types with default values in SQLite.
Swaathi Kakarla

Rails 7 updates through_reflection to distribute transactions across database connections

Models that use multiple databases now perform writes within a single transaction.
Swaathi Kakarla

Rails extends routes searching to include dynamic URL params

Now search for `cats/10/toys/15` instead of `cats/:cat_id/toys/:id`, making it easier to find the route you're looking for.
Swaathi Kakarla

Rails 7 now reads ENV["SCHEMA_FORMAT"] when doing rails db:schema:{dump,load}

Previously rails db:schema:{dump,load} would only dump Ruby format. Now it reads ENV["SCHEMA_FORMAT"] to choose between Ruby and SQL formats.
Swaathi Kakarla

ActiveRecord methods touch and update_columns no longer work for readonly models

Readonly models get updated when touch or update_columns is called.
Swaathi Kakarla

Rails 7 now accepts "html" and "screenshot" kwargs for system test screenshot helper

Pass in parameters to take_screenshot to choose an output format between image and HTML file.
Swaathi Kakarla

Rails 7 now lazy loads schema cache

Use a config option to now switch between eager and lazy schema cache loading.
Swaathi Kakarla

Rails does not require role when to be passed to connected_to

The connected_to block no longer throws an ArgumentError when called without a role parameter so as to pave the way for a more simplified and buildable syntax.
Swaathi Kakarla

Rails adds the ability to prevent unwarranted shard swapping

Rails provides the config option ActiveRecord::Base.prohibit_shard_swapping that prevents swapping of database shards.
Swaathi Kakarla

Rails loads ActionCable via Zeitwerk

Zeitwerk is a new thread-safe code loader introduced in Rails 6. Now, ActionCable and other related modules are loaded via Zeitwerk.
Swaathi Kakarla

Rails conforms to destroy_association_async_job config when destroying asynchronously

Rails no longer ignores the configuration option destroy_association_async_job when destroying objects with destroy_async option.
Swaathi Kakarla

Rails 7 adds support for setting the schema dump filepath in the database config

Schema dumps can now be toggled and dump filepaths can be set for individual database shards.
Swaathi Kakarla

Rails provides better ActiveRecord enum assertions

ActiveRecord now explicitly checks if the enum values are empty by raising an ArgumentError.
Swaathi Kakarla

Ruby Fibers 101

Ruby 3 focuses more on concurrency with the introduction of Ruby Fibers and the Fiber Scheduler Interface.
Swaathi Kakarla

Rails adds support for Fiber-safe ActiveRecord ConnectionPools

ActiveRecord's ConnectionPool is now fiber-safe! Adjust the value of config.active_support.isolation_level to either rely on threads or fibers to give a better throughput on fiber-oriented servers like Falcon.
Swaathi Kakarla

Rails drops records not listed in QueryMethods#in_order_of

QueryMethods#in_order_of now filters down to only the values provided, matching the behavior of the eponymous Enumerable method.
Swaathi Kakarla

ActiveRecord::Core "#find" now reuses "#find_by" cache key

ActiveRecord::Core now prevents duplicate entries in find/find_by cache resulting in slightly improved performance.
Swaathi Kakarla

Rails 7 raise ActionController::Redirecting::UnsafeRedirectError for unsafe redirects

Now unsafe redirects raise a UnsafeRedirectError instead of an ArgumentError.
Swaathi Kakarla

Rails 7 now allows automatic inverse_of detection for associations with scopes

This update ensures that "inverse_of" takes into consideration the relevant scope when calculating the object to store in memory.
Swaathi Kakarla

Rails introduces ActiveRecord::Persistence#update_attribute!

While update_attribute was used to bypass validations, update_attribute! now does the same but raises ActiveRecord::RecordNotSaved in case of any errors encountered in `before_*` callbacks.
Swaathi Kakarla

Rails 7 now introduces support for generated columns with Postgres

Rails 7 now adds support for generated (virtual) columns to the PostgreSQL adapter that has been available since PSQL v12.
Swaathi Kakarla

Rails 7 renders accurate plain text output for nested fields

Plain text rendering of nested fields now reserves indentation.
Swaathi Kakarla

Rails 7 allows setting timestamps on insert_all/upsert_all record creation

All relevant timestamp columns (`created_at`, `created_on`, `updated_at`, `updated_on`) are now set via ActiveRecord when using mass insertion queries.
Swaathi Kakarla

Rails 7 adds better support for custom enum types in PostgreSQL

With Rails 7, use create_enum to add a new enum type and t.enum to add a column.
Swaathi Kakarla

PostgreSQL data-types in Rails

With Rails, there are many built-in data types that PostgreSQL supports. It's a great addition to the developer's toolkit!
Swaathi Kakarla

Rails 7 adds the ability to delete and update queries using GROUP_BY and HAVING

With Rails 7, we can now combine GROUP_BY and HAVING clauses with a more complex update and delete queries.
Swaathi Kakarla

Rails 7 adds :day_format option to date_select

Now format how the day looks in a date select dropdown using `day_format`.
Swaathi Kakarla

Rails 7: Pass default values to I18n's `translate` method

Provide fallback values to the translate method apart from those parts of the translation string.
Swaathi Kakarla

Rails 7 adds the ability to check if a location is safe before redirecting

Now determine if a URL is an internal one before redirecting.
Swaathi Kakarla

Rails 7 replaces Webpacker with importmapped Hotwire as default JavaScript setup

A new Rails skeleton will not have to require the full JavaScript toolchain with Webpack by default as Rails 7 embraces the future of Javascript.
Swaathi Kakarla

Rails 7 adds the possibility to check on :priority for ActiveJob tests

Rails 7 gives us option to set `:priority` in test helper methods `assert_enqueued_with` and `assert_performed_with`.
Swaathi Kakarla

Rails 7 adds choices to Javascript generator option

Rails 7 introduces built-in support for webpacker and esbuild.
Swaathi Kakarla

Rails 7: Instrument ActiveStorage analyzers

Rails 7 adds instrumentation for ActiveStorage analyzers so that the time of analysis can be tracked.
Swaathi Kakarla

Rails 7: Add from: option to ActiveSupport::TestCase#assert_no_changes

ActiveSupport::TestCase#assert_no_changes adds additional options.
Swaathi Kakarla

Essential Skills For A Senior Rails Developer

Programming is a skill and, just like any skill, to get better at it one needs to practice, practice and practice!
Swaathi Kakarla

Rails Arel Primer

The first look into Arel, its advantages, and examples.
Swaathi Kakarla

Rails 7 supports NullsFirst for all databases

Developers can now access Arel methods for null column ordering.
Swaathi Kakarla

Rails 7 adds Marginalia to Query Logs

With this update, Marginalia SQL comments are added to Rails as a native feature!
Swaathi Kakarla

Rails 7 adds attributes_for_database to return attributes as they would be in the database

Before this update, serializing an ActiveRecord object led to funny outcomes. Let's dive in!
Swaathi Kakarla

Rails 7 now consistently renders button_to

Rails 7 introduced a config that helps button_to consistently render out to the button HTML tag.
Swaathi Kakarla

ActiveStorage now raises a PreviewError when previews fail to generate

Before this update, a failed preview generation would result in a 0-byte file being created – leading to disastrous outcomes in the views.
Swaathi Kakarla

Rails 7 moves ActiveRecord::Base.logger to a class_attribute leading to a 7x speed improvement

Rails 7 utilized Ruby's cache for cvars to improve ActiveRecord::Base.logger performance 7x. Let's deep dive into this!
Swaathi Kakarla

ActiveRecord::Calculations will now use column-based type casting

Rails 7 now harmonizes results of ActiveRecord::Calculations.average by applying column-based typecasting. Now, floating-point number columns will be aggregated as Float.
Swaathi Kakarla

Rails 7 adds change tracking methods for belongs_to associations

Rails 7 adds the ability to track if an association has been pointed to a new target record in the previous save and whether it will point to a new target record in the next save.
Swaathi Kakarla

Rails now serves files via proxy

Rails 6.1 has added support to ActiveStorage that serves files via proxying.
Swaathi Kakarla

Rails 7 adds the ability to schedule the query on the background thread pool

Rails 7 adds the ability to push database queries to the background thread pool, effectively reducing load times by utilizing I/O waits.
Swaathi Kakarla

Rails 7 adds direct ActiveStorage::Streaming support

Rails 7 adds a method to stream directly from your own controllers.
Swaathi Kakarla

Rails 7 adds ActiveRecord methods `#sole` and `#find_sole_by`

Rails 7 adds ActiveRecord methods `#sole` and `#find_sole_by` to uniquely match only one record in a database.
Swaathi Kakarla

Rails 6.1 adds config option to control image_tag loading attribute

Rails 6.1 adds a config option to set a default value for the loading attribute of all image_tags. This is in line with the latest official HTML standard.
Swaathi Kakarla

Rails form_with now defaults to non-remote forms

Rails form generation helper, "form_with" defaulted to remote forms previously. This would confuse beginners who would expect an HTML response to be rendered. Now, you can configure the default response type.