mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
088c11658a
Now that Validator #setup is called from the initializer, we need a reference to the model's class to be passed in to allow the validators to continue functioning when used at the instance level. Closes #14134.
13 lines
284 B
Ruby
13 lines
284 B
Ruby
class Automobile
|
|
include ActiveModel::Validations
|
|
|
|
validate :validations
|
|
|
|
attr_accessor :make, :model, :approved
|
|
|
|
def validations
|
|
validates_presence_of :make
|
|
validates_length_of :model, within: 2..10
|
|
validates_acceptance_of :approved, allow_nil: false
|
|
end
|
|
end
|