- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
- No changes.
-
Fix regression in numericality validator when comparing Decimal and Float input values with more scale than the schema.
Bradley Priest
-
The original string assigned to a model attribute is no longer incorrectly frozen.
Fixes #24185, #28718.
Matthew Draper
-
Avoid converting integer as a string into float.
namusyaka
- No changes.
- No changes.
- No changes.
-
Fix
Type::Date#serializeto cast a value to a date object properly. This casting fixes queries for finding records by date column.Fixes #25354.
Ryuta Kamizono
-
Dirty's*_changed?methods now return an actual singleton, nevernil, as in 4.2. Fixes #24220.Sen-Zhang
-
Ensure that instances of
ActiveModel::Errorscan be marshalled. Fixes #25165.Sean Griffin
-
Allow passing record being validated to the message proc to generate customized error messages for that object using I18n helper.
Prathamesh Sonpatki
-
Validate multiple contexts on
valid?andinvalid?at once.Example:
class Person include ActiveModel::Validations attr_reader :name, :title validates_presence_of :name, on: :create validates_presence_of :title, on: :update end person = Person.new person.valid?([:create, :update]) # => false person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]}Dmitry Polushkin
-
Add case_sensitive option for confirmation validator in models.
Akshat Sharma
-
Ensure
method_missingis called for methods passed toActiveModel::Serialization#serializable_hashthat don't exist.Jay Elaraj
-
Remove
ActiveModel::Serializers::Xmlfrom core.Zachary Scott
-
Add
ActiveModel::Dirty#[attr_name]_previously_changed?andActiveModel::Dirty#[attr_name]_previous_changeto improve access to recorded changes after the model has been saved.It makes the dirty-attributes query methods consistent before and after saving.
Fernando Tapia Rico
-
Deprecate the
:tokenizeroption forvalidates_length_of, in favor of plain Ruby.Sean Griffin
-
Deprecate
ActiveModel::Errors#add_on_emptyandActiveModel::Errors#add_on_blankwith no replacement.Wojciech Wnętrzak
-
Deprecate
ActiveModel::Errors#get,ActiveModel::Errors#setandActiveModel::Errors#[]=methods that have inconsistent behavior.Wojciech Wnętrzak
-
Allow symbol as values for
tokenizeofLengthValidator.Kensuke Naito
-
Assigning an unknown attribute key to an
ActiveModelinstance during initialization will now raiseActiveModel::AttributeAssignment::UnknownAttributeErrorinstead ofNoMethodError.Example:
User.new(foo: 'some value') # => ActiveModel::AttributeAssignment::UnknownAttributeError: unknown attribute 'foo' for User.Eugene Gilburg
-
Extracted
ActiveRecord::AttributeAssignmenttoActiveModel::AttributeAssignmentallowing to use it for any object as an includable module.Example:
class Cat include ActiveModel::AttributeAssignment attr_accessor :name, :status end cat = Cat.new cat.assign_attributes(name: "Gorby", status: "yawning") cat.name # => 'Gorby' cat.status # => 'yawning' cat.assign_attributes(status: "sleeping") cat.name # => 'Gorby' cat.status # => 'sleeping'Bogdan Gusiev
-
Add
ActiveModel::Errors#detailsTo be able to return type of used validator, one can now call
detailson errors instance.Example:
class User < ActiveRecord::Base validates :name, presence: true end user = User.new; user.valid?; user.errors.details => {name: [{error: :blank}]}Wojciech Wnętrzak
-
Change
validates_acceptance_ofto accepttrueby default besides'1'.The default for
validates_acceptance_ofis now'1'andtrue. In the past, only"1"was the default and you were required to passaccept: trueseparately.mokhan
-
Remove deprecated
ActiveModel::Dirty#reset_#{attribute}andActiveModel::Dirty#reset_changes.Rafael Mendonça França
-
Change the way in which callback chains can be halted.
The preferred method to halt a callback chain from now on is to explicitly
throw(:abort). In the past, returningfalsein an Active Modelbefore_callback had the side effect of halting the callback chain. This is not recommended anymore and, depending on the value of theActiveSupport.halt_callback_chains_on_return_falseoption, will either not work at all or display a deprecation warning.claudiob
Please check 4-2-stable for previous changes.