1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test/models/automobile.rb
Eric Hutzelman 088c11658a Fix some validators when used on model instance
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.
2014-02-26 21:35:49 -03:00

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