Swaathi Kakarla

Swaathi Kakarla

Swaathi Kakarla is a Ruby on Rails Developer.
authorImg Swaathi Kakarla

Rails 7.1.2 now ignores implicitly passed locals in templates that use strict local definitions

Templates that use strict locals can not accept anything other than those defined. This previously raised exceptions for implicitly passed locals that a user is unaware of.
authorImg Swaathi Kakarla

Rails introduces ErrorReporter#unexpected for reporting precondition violations

The new method will report in production but raise in other environments, making it easier to debug.
authorImg Swaathi Kakarla

Upsert no longer ignores on_duplicate if unique_by is specified

Upsert would previously not execute the on_duplicate clause if the unique_by constraint found a match. This has been fixed.
authorImg Swaathi Kakarla

ActiveStorage now pre-processes PDFs and videos

Rails now pre-processes previewable files such as PDFs and videos. Previously it only pre-processed images.
authorImg 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.
authorImg 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?.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg Swaathi Kakarla

Rails 7.1 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg Swaathi Kakarla

Rails 7 now lazy loads schema cache

Use a config option to now switch between eager and lazy schema cache loading.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg Swaathi Kakarla

Rails provides better ActiveRecord enum assertions

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

Ruby Fibers 101

Ruby 3 focuses more on concurrency with the introduction of Ruby Fibers and the Fiber Scheduler Interface.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg Swaathi Kakarla

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

Now unsafe redirects raise a UnsafeRedirectError instead of an ArgumentError.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg Swaathi Kakarla

Rails 7 renders accurate plain text output for nested fields

Plain text rendering of nested fields now reserves indentation.
authorImg 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.
authorImg 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.
authorImg 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!
authorImg 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.
authorImg 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`.
authorImg 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.
authorImg 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.
authorImg 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.
authorImg 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`.
authorImg Swaathi Kakarla

Rails 7 adds choices to Javascript generator option

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

Rails 7: Instrument ActiveStorage analyzers

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

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

ActiveSupport::TestCase#assert_no_changes adds additional options.
authorImg 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!
authorImg Swaathi Kakarla

Rails Arel Primer

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

Rails 7 supports NullsFirst for all databases

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

Rails 7 adds Marginalia to Query Logs

With this update, Marginalia SQL comments are added to Rails as a native feature!
authorImg 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!
authorImg 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.
authorImg 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.
authorImg 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!
authorImg 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.
authorImg 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.
authorImg Swaathi Kakarla

Rails now serves files via proxy

Rails 6.1 has added support to ActiveStorage that serves files via proxying.
authorImg 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.
authorImg Swaathi Kakarla

Rails 7 adds direct ActiveStorage::Streaming support

Rails 7 adds a method to stream directly from your own controllers.
authorImg 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.
authorImg 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.
authorImg 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.