7
8
9
10
11
12
13
14
15
16
|
# File 'lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb', line 7
def initialize_with_validation_reflection(name, active_record_class)
initialize_without_validation_reflection(name, active_record_class)
column_names = [name]
column_names << @association.primary_key_name if @association
self.required = column_names.any? do |column_name|
active_record_class.reflect_on_validations_for(column_name.to_sym).any? do |val|
val.macro == :validates_presence_of or (val.macro == :validates_inclusion_of and not val.options[:allow_nil] and not val.options[:allow_blank])
end
end
end
|