Skip to content
Browse files

refactoring find_join_association

  • Loading branch information...
1 parent 0bb85ed commit 67a3a702951dae905b6270d652dbd14853b01c26 @tenderlove tenderlove committed Oct 30, 2010
Showing with 6 additions and 5 deletions.
  1. +6 −5 activerecord/lib/active_record/associations.rb
View
11 activerecord/lib/active_record/associations.rb
@@ -1960,12 +1960,13 @@ def build(associations, parent = nil, join_type = Arel::InnerJoin)
end
def find_join_association(name_or_reflection, parent)
- case name_or_reflection
- when Symbol, String
- join_associations.detect {|j| (j.reflection.name == name_or_reflection.to_s.intern) && (j.parent == parent)}
- else
- join_associations.detect {|j| (j.reflection == name_or_reflection) && (j.parent == parent)}
+ if String === name_or_reflection
+ name_or_reflection = name_or_reflection.to_sym
end
+
+ join_associations.detect { |j|
+ j.reflection == name_or_reflection && j.parent == parent
+ }
end
def remove_uniq_by_reflection(reflection, records)

2 comments on commit 67a3a70

@ernie
Ruby on Rails member
ernie commented on 67a3a70 Oct 30, 2010

That's not quite a refactor. Converting to symbol in the case of a string and then checking the symbol against j.reflection instead of j.reflection.name isn't the same functionality. That being said, as I think I mentioned in the ticket, stock Rails never needs the symbol lookup anyway at this time. That's a leftover from the fact that the method was a MetaWhere extraction.

@tenderlove
Ruby on Rails member

oh crap. I totally missed that. The tests passed though... strange.

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