Skip to content
Browse files

Make HasManyThroughSourceAssociationNotFoundError use _reflections

- No need to use .map(:to_s)
- Add @api public to reflections
  • Loading branch information...
1 parent 5657f5f commit f625f78a1f53895f340af9d8432788170f5477d1 @arthurnn arthurnn committed May 21, 2014
Showing with 2 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/associations.rb
  2. +1 −0 activerecord/lib/active_record/reflection.rb
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 = {}

0 comments on commit f625f78

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