Happy Friday! This is Greg, bringing you the latest changes in the Rails codebase. It was a quiet week, but there are still noteworthy changes, let’s explore them.
Read from ENV[‘REVISION’] if present
Rails.app.revision now checks ENV["REVISION"] before falling back to the REVISION file or git.
Improve error page to make nested stack traces more discoverable
This pull request adds a small arrow on the side of the summary bar of the error page in development and it can be clicked to reveal the stack trace.
Pass SQL query to query log tags
With this change, the SQL query is passed to query log tags. If you are using
the query log tags for debugging, you can access the SQL query like this:
config.active_record.query_log_tags = [
sql_length: ->(context) { context[:sql].length }
]
Add unique_by option to insert_all!
insert_all! has a new unique_by option now for PostgreSQL and SQLite. By default rows are considered to be unique by every unique index on the table.
To check uniqueness according to just one unique index, pass the :unique_by option to the method.
Unique indexes can be identified by columns or name:
unique_by: :isbn
unique_by: %i[ author_id name ]
unique_by: :index_books_on_isbn
The same behavior already exist on insert_all.
You can view the whole list of changes here.
We had 19 contributors to the Rails codebase this past week!
Until next time!
Subscribe to get these updates mailed to you.