Friday, July 26, 2024

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

Posted by zzak

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'"

Add “cvv” and “cvc” as default parameters to filter out in new apps
For new apps, this PR adds cvv and cvc to the defaults for ActiveSupport::ParameterFilter.

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!

Subscribe to get these updates mailed to you.