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/topic.rb
Neeraj Singh 2ffa50f5a9 after_validation should be called irrespective of the result of validation.
I confirmed that this is the behavior on 2.3.x .

[5419 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-20 11:24:43 -03:00

28 lines
534 B
Ruby

class Topic
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
attr_accessor :title, :author_name, :content, :approved
attr_accessor :after_validation_performed
after_validation :perform_after_validation
def initialize(attributes = {})
attributes.each do |key, value|
send "#{key}=", value
end
end
def condition_is_true
true
end
def condition_is_true_but_its_not
false
end
def perform_after_validation
self.after_validation_performed = true
end
end