Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 05, 2012
Nico rails 3.2 fixes 60320e6
Commits on Feb 27, 2013
@electronicbites Merge pull request #1 from ncri/master
rails 3.2
534b527
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/validation_reflection.rb
View
8 lib/validation_reflection.rb
@@ -33,6 +33,8 @@ def included(base) # :nodoc:
# for later easy access.
#
def install(base)
+ base.send :class_attribute, :validations
+
@@reflected_validations.each do |validation_type|
next if base.respond_to?(:"#{validation_type}_with_reflection")
ignore_subvalidations = false
@@ -62,7 +64,7 @@ module ClassMethods
# Returns an array of MacroReflection objects for all validations in the class
def reflect_on_all_validations
- self.read_inheritable_attribute(:reflected_validations) || []
+ validations || []
end
# Returns an array of MacroReflection objects for all validations defined for the field +attr_name+.
@@ -78,9 +80,9 @@ def reflect_on_validations_for(attr_name)
#
def remember_validation_metadata(validation_type, *attr_names)
configuration = attr_names.last.is_a?(::Hash) ? attr_names.pop : {}
+ self.validations ||= []
attr_names.flatten.each do |attr_name|
- self.write_inheritable_array :reflected_validations,
- [::ActiveRecord::Reflection::MacroReflection.new(validation_type, attr_name.to_sym, configuration, self)]
+ self.validations << ::ActiveRecord::Reflection::MacroReflection.new(validation_type, attr_name.to_sym, configuration, self)
end
end

No commit comments for this range

Something went wrong with that request. Please try again.