This Week in Rails

July 27, 2024

Model Missing Attributes, SQLite Immediate Transactions, and CVV/CVC Parameter Filtering by default

Hi, it’s zzak. This is a short week, but let’s jump in.

Drop Hash#except core extension
Rails 8.0 will be Ruby 3.1 or greater only except natively got added in Ruby 3.0 so this is dead code now.

Introduce ActiveModel::AttributeAssignment#attribute_writer_missing
Provide instances with an opportunity to gracefully handle assigning to an unknown attribute:
class Rectangle
  include ActiveModel::AttributeAssignment

  attr_accessor :length, :width

  def attribute_writer_missing(name, value)
    Rails.logger.warn "Tried to assign to unknown attribute #{name}"
  end
end

rectangle = Rectangle.new
rectangle.assign_attributes(height: 10)
  # => Logs "Tried to assign to unknown attribute 'height'"

Ensure SQLite transaction default to IMMEDIATE mode
This PR updates the SQLite adapter to use IMMEDIATE mode whenever possible in order to improve concurrency support and avoid busy exceptions.

You can view the whole list of changes here. We had 15 contributors to the Rails codebase this past week!

Until next time!

About This Week in Rails

Your weekly inside scoop of interesting commits, pull requests and more from Rails.