Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure validate_presence_of matcher works with non AR classes.

  • Loading branch information...
commit 9b591f16b3043edaf753ad96d3ff1bc3a64cd773 1 parent 3e37f94
Carlos Antonio da Silva carlosantoniodasilva authored josevalim committed
10 remarkable_activerecord/lib/remarkable_activerecord/matchers/validate_presence_of_matcher.rb
View
@@ -54,13 +54,21 @@ def blank_value
end
def collection?
- if reflection = subject_class.reflect_on_association(@attribute)
+ if reflection = find_reflection
[:has_many, :has_and_belongs_to_many].include?(reflection.macro)
else
false
end
end
+ private
+
+ def find_reflection
+ if subject_class.respond_to?(:reflect_on_association)
+ subject_class.reflect_on_association(@attribute)
+ end
+ end
+
end
# Ensures that the model cannot be saved if one of the attributes listed is not present.
Please sign in to comment.
Something went wrong with that request. Please try again.