Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make HasManyThroughSourceAssociationNotFoundError use _reflections

- No need to use .map(:to_s)
- Add @api public to reflections
  • Loading branch information...
commit f625f78a1f53895f340af9d8432788170f5477d1 1 parent 5657f5f
@arthurnn arthurnn authored
View
2  activerecord/lib/active_record/associations.rb
@@ -50,7 +50,7 @@ class HasManyThroughSourceAssociationNotFoundError < ActiveRecordError #:nodoc:
def initialize(reflection)
through_reflection = reflection.through_reflection
source_reflection_names = reflection.source_reflection_names
- source_associations = reflection.through_reflection.klass.reflections.keys.map(&:to_s)
+ source_associations = reflection.through_reflection.klass._reflections.keys
super("Could not find the source association(s) #{source_reflection_names.collect{ |a| a.inspect }.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?")
end
end
View
1  activerecord/lib/active_record/reflection.rb
@@ -5,6 +5,7 @@ module Reflection # :nodoc:
included do
class_attribute :_reflections
+ # @api public
class_attribute :reflections
class_attribute :aggregate_reflections
self._reflections = {}
Please sign in to comment.
Something went wrong with that request. Please try again.