Rails 7.1 Composite Primary Key Support
ActiveRecord models can now be configured with composite primary keys, making it easier to work with complex data models.Rails 7.1.2 Ignores Implicit Strict Locals
Templates that use strict locals can not accept anything other than those defined.Rails ErrorReporter#unexpected Method
The new method will report in production but raise in other environments, making it easier to debug.Upsert Respects on_duplicate with unique_by
Upsert would previously not execute the on_duplicate clause if the unique_by constraint found a match. This has been fixed.ActiveStorage Pre-processes PDFs & Videos
Rails now pre-processes previewable files such as PDFs and videos. Previously it only pre-processed images.Rails Optimizes AR Batch Iterations
Response times for batch queries have significantly improved by moving to a range-based iteration strategy.Enumerable#many? Forwards Parameters
When used in conjunction with each_with_index Enumerable#many? does not forward index parameter unlike Enumerable#any?.Rails Store Serializes as Regular Hash
Serializing store objects with ActiveSupport::HashWithIndifferentAccess is both a wasteful and an insecure option.Ruby Data Class for Immutable Objects
The Data class helps define simple classes for value-alike objects that can be extended with custom methods.Rails Pending Migrations Show Path
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.Rails 7.1 Job Generator --parent
Similar to the working of the model generator, the job generator now accepts the --parent option.Rails 7 Fixes tsrange Timezone Bug
Earlier the tsrange/tstzrange column would throw a TypeError if a timezone was set in the application config.Rails Adds SQLite :strict Option
SQLite can be configured to be strict to circumvent some of its quirks. Rails can now specify this in the default database.yml file.Rails Validates Migration Options
Previously erroneous options were silently ignored in migration functions such as "create_table" or "add_column", now they raise an error.Rails assert_redirected_to Status Code
The assertion statement previous was only able to assert that the request was redirected, but not the status code.Rails ErrorReporting source Attribute
Subscribers can now filter error reports based on source, making it easier to ignore internal errors or focus on specific errors.Rails Requires active_storage.service
Developers are no longer presented vague errors when config.active_storage.service is not set. Instead a clear exception is raised.Rails Infinite Range in LengthValidators
Models that need to be validated for length can use infinite ranges in :in / :within optionsRails Fixes Mutable Param Cache Hits
ActiveRecord now dups and freezes complex types when making query attributes which prevents false-positive query cache hits.Rails EML Download from 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.Rails Improves in_order_of Method
The query that previously only used to allow symbolic column names, now handles string values.Rails error_highlight for Error Location
With the help of Ruby 3.1's error_highlight functionality, Rails can now pinpoint the exact column where an error is present.Rails 7 SQLite Binary Column Defaults
Binary columns now behave like other column types with default values in SQLite.Rails 7 through_reflection Transactions
Models that use multiple databases now perform writes within a single transaction.Rails Routes Search with Dynamic 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.Rails 7 SCHEMA_FORMAT Environment Var
Previously rails db:schema:{dump,load} would only dump Ruby format. Now it reads ENV["SCHEMA_FORMAT"] to choose between Ruby and SQL formats.ActiveRecord Readonly Model Restrictions
Readonly models get updated when touch or update_columns is called.Rails 7 Screenshot Helper Options
Pass in parameters to take_screenshot to choose an output format between image and HTML file.Rails 7 now lazy loads schema cache
Use a config option to now switch between eager and lazy schema cache loading.Rails connected_to Without Role
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.Rails Prevents Unwarranted Shard Swapping
Rails provides the config option ActiveRecord::Base.prohibit_shard_swapping that prevents swapping of database shards.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.Rails destroy_association_async_job Config
Rails no longer ignores the configuration option destroy_association_async_job when destroying objects with destroy_async option.Rails 7 Schema Dump Path Config
Schema dumps can now be toggled and dump filepaths can be set for individual database shards.Rails Adds Better Enum Assertions
ActiveRecord now explicitly checks if the enum values are empty by raising an ArgumentError.Ruby Fibers 101: A Complete Guide
Ruby 3 focuses more on concurrency with the introduction of Ruby Fibers and the Fiber Scheduler Interface.Rails Fiber-Safe Connection Pools
ActiveRecord's ConnectionPool is now fiber-safe! Configure config.active_support.isolation_level for better throughput.Rails in_order_of Drops Unlisted Records
QueryMethods#in_order_of now filters down to only the values provided, matching the behavior of the eponymous Enumerable method.ActiveRecord find Reuses find_by Cache
ActiveRecord::Core now prevents duplicate entries in find/find_by cache resulting in slightly improved performance.Rails 7 Raises UnsafeRedirectError
Now unsafe redirects raise a UnsafeRedirectError instead of an ArgumentError.Rails 7 Auto inverse_of Detection
This update ensures that "inverse_of" takes into consideration the relevant scope when calculating the object to store in memory.Rails 7 Adds update_attribute! Method
While update_attribute was used to bypass validations, update_attribute! now does the same but raises ActiveRecord::RecordNotSaved in case of any errorsRails 7 PostgreSQL Generated Columns
Rails 7 now adds support for generated (virtual) columns to the PostgreSQL adapter that has been available since PSQL v12.Rails 7 Plain Text for Nested Fields
Plain text rendering of nested fields now reserves indentation.Rails 7 Timestamps in insert_all
All relevant timestamp columns (`created_at`, `created_on`, `updated_at`, `updated_on`) are now set via ActiveRecord when using mass insertion queries.Rails 7 PostgreSQL Custom Enum Types
With Rails 7, use create_enum to add a new enum type and t.enum to add a column.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!Rails 7 GROUP BY and HAVING in Updates
With Rails 7, we can now combine GROUP_BY and HAVING clauses with a more complex update and delete queries.Rails 7 date_select :day_format Option
Now format how the day looks in a date select dropdown using `day_format`.Rails 7 I18n translate Defaults
Provide fallback values to the translate method apart from those parts of the translation string.Rails 7 Safe Redirect Location Check
Now determine if a URL is an internal one before redirecting.Rails 7 Import Maps Replace Webpacker
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.Rails 7 ActiveJob Priority Testing
Rails 7 gives us option to set `:priority` in test helper methods `assert_enqueued_with` and `assert_performed_with`.Rails 7 JavaScript Generator Options
Rails 7 introduces built-in support for webpacker and esbuild.Rails 7: Instrument ActiveStorage analyzers
Rails 7 adds instrumentation for ActiveStorage analyzers so that the time of analysis can be tracked.Rails 7 from: Option in assert_no_changes
ActiveSupport::TestCase#assert_no_changes adds additional options.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!Rails Arel Guide: Build Complex SQL Queries in Ruby
Learn Rails Arel to build reusable, readable SQL queries. Covers Arel tables, predicates, joins, aggregates, and query composition patterns.Rails 7 supports NullsFirst for all databases
Developers can now access Arel methods for null column ordering.Rails 7 adds Marginalia to Query Logs
With this update, Marginalia SQL comments are added to Rails as a native feature!Rails 7 Adds attributes_for_database
Before this update, serializing an ActiveRecord object led to funny outcomes. Let's dive in!Rails 7 now consistently renders button_to
Rails 7 introduced a config that helps button_to consistently render out to the button HTML tag.ActiveStorage Raises PreviewError
Before this update, a failed preview generation would result in a 0-byte file being created – leading to disastrous outcomes in the views.Rails 7 Faster Logger with class_attribute
Rails 7 utilized Ruby's cache for cvars to improve ActiveRecord::Base.logger performance 7x. Let's deep dive into this!ActiveRecord Column-Based Type Casting
Rails 7 now harmonizes results of ActiveRecord::Calculations.average by applying column-based typecasting.Rails 7 belongs_to Change Tracking
Rails 7 adds association_changed? and association_previously_changed? methods for belongs_to associations.Rails now serves files via proxy
Rails 6.1 has added support to ActiveStorage that serves files via proxying.Rails 7 Adds Async Query Support
Rails 7 adds the ability to push database queries to the background thread pool, effectively reducing load times by utilizing I/O waits.Rails 7 Adds ActiveStorage Streaming
Rails 7 adds a method to stream directly from your own controllers.Rails 7 Adds sole and find_sole_by Methods
Rails 7 adds ActiveRecord methods `#sole` and `#find_sole_by` to uniquely match only one record in a database.Rails 6.1 Adds Lazy Image Loading Config
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.Rails form_with Defaults to Non-Remote
Rails form generation helper, "form_with" defaulted to remote forms previously.