Skip to content
Browse files

simplify the JoinAssociation constructor, check validity *before*

  • Loading branch information...
1 parent 4c0f023 commit 6141d0c4b84a765464852df1dfa06995bba22023 @tenderlove tenderlove committed Oct 3, 2013
View
6 activerecord/lib/active_record/associations/join_dependency.rb
@@ -174,6 +174,12 @@ def remove_uniq_by_reflection(reflection, records)
end
def build_join_association(reflection, parent)
+ reflection.check_validity!
+
+ if reflection.options[:polymorphic]
+ raise EagerLoadPolymorphicError.new(reflection)
+ end
+
JoinAssociation.new(reflection, self, parent)
end
View
6 activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -30,12 +30,6 @@ class JoinAssociation < JoinPart # :nodoc:
delegate :alias_tracker, :to => :join_dependency
def initialize(reflection, join_dependency, parent)
- reflection.check_validity!
-
- if reflection.options[:polymorphic]
- raise EagerLoadPolymorphicError.new(reflection)
- end
-
super(reflection.klass)
@reflection = reflection

0 comments on commit 6141d0c

Please sign in to comment.
Something went wrong with that request. Please try again.