Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't access the reflections hash

The reflections hash is supposed to be private, so let's use the API.
  • Loading branch information...
commit 7e5c5e4d8c6c9346b8669db9faa4c3dced374646 1 parent 9560369
@tenderlove tenderlove authored
View
8 activerecord/lib/active_record/associations/join_dependency.rb
@@ -144,11 +144,15 @@ def cache_joined_association(association, tree)
ref[association.reflection.name] ||= {}
end
+ def find_reflection(klass, name)
+ klass.reflect_on_association(name.intern) or
+ raise ConfigurationError, "Association named '#{ name }' was not found on #{ klass.name }; perhaps you misspelled it?"
+ end
+
def build(associations, parent, join_type)
case associations
when Symbol, String
- reflection = parent.reflections[associations.intern] or
- raise ConfigurationError, "Association named '#{ associations }' was not found on #{ parent.base_klass.name }; perhaps you misspelled it?"
+ reflection = find_reflection parent.base_klass, associations
unless join_association = find_join_association(reflection, parent)
@reflections << reflection
join_association = build_join_association(reflection, parent, join_type)
View
2  activerecord/lib/active_record/associations/join_dependency/join_part.rb
@@ -13,7 +13,7 @@ class JoinPart # :nodoc:
# association.
attr_reader :base_klass
- delegate :table_name, :column_names, :primary_key, :reflections, :arel_engine, :to => :base_klass
+ delegate :table_name, :column_names, :primary_key, :arel_engine, :to => :base_klass
def initialize(base_klass)
@base_klass = base_klass
Please sign in to comment.
Something went wrong with that request. Please try again.