include validations on ancestors #855

Closed
wants to merge 1 commit into from
View
7 lib/formtastic/inputs/base/validations.rb
@@ -23,9 +23,10 @@ def message
def validations
@validations ||= if object && object.class.respond_to?(:validators_on)
- object.class.validators_on(attributized_method_name).select do |validator|
- validator_relevant?(validator)
- end
+ object.class.ancestors.
+ select { |ancestor| ancestor.respond_to?(:validators_on) }.
+ inject([]) { |validators, ancestor| validators + ancestor.validators_on(attributized_method_name) }.
+ select { |validator| validator_relevant?(validator) }
else
nil
end