aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-09 19:19:59 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-09 19:19:59 -0700
commit82cb4777c148962467b04ee29fb49063462c56d8 (patch)
tree451bcb8377ba1aa70521f954440edafa32ae53bb /activerecord/lib/active_record
parentc7d009b35e2b6b35352eaeba6290b67e8afffdb1 (diff)
parent213ef567ae2ab92f1e1145cd385da0c5b9534422 (diff)
downloadrails-82cb4777c148962467b04ee29fb49063462c56d8.tar.gz
rails-82cb4777c148962467b04ee29fb49063462c56d8.tar.bz2
rails-82cb4777c148962467b04ee29fb49063462c56d8.zip
Merge pull request #14675 from laurocaetano/make_reflection_caches_works_with_string_keys
Make reflection and aggregate_reflection caches work with string keys.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/reflection.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 5465a7bfd7..1ce477f38b 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -22,11 +22,11 @@ module ActiveRecord
end
def self.add_reflection(ar, name, reflection)
- ar.reflections = ar.reflections.merge(name => reflection)
+ ar.reflections = ar.reflections.merge(name.to_s => reflection)
end
def self.add_aggregate_reflection(ar, name, reflection)
- ar.aggregate_reflections = ar.aggregate_reflections.merge(name => reflection)
+ ar.aggregate_reflections = ar.aggregate_reflections.merge(name.to_s => reflection)
end
# \Reflection enables to interrogate Active Record classes and objects
@@ -48,7 +48,7 @@ module ActiveRecord
# Account.reflect_on_aggregation(:balance) # => the balance AggregateReflection
#
def reflect_on_aggregation(aggregation)
- aggregate_reflections[aggregation]
+ aggregate_reflections[aggregation.to_s]
end
# Returns an array of AssociationReflection objects for all the
@@ -72,7 +72,7 @@ module ActiveRecord
# Invoice.reflect_on_association(:line_items).macro # returns :has_many
#
def reflect_on_association(association)
- reflections[association]
+ reflections[association.to_s]
end
# Returns an array of AssociationReflection objects for all associations which have <tt>:autosave</tt> enabled.
@@ -617,11 +617,11 @@ module ActiveRecord
# # => [:tag, :tags]
#
def source_reflection_names
- (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym }.uniq
+ (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n }.uniq
end
def source_reflection_name # :nodoc:
- return @source_reflection_name.to_sym if @source_reflection_name
+ return @source_reflection_name if @source_reflection_name
names = [name.to_s.singularize, name].collect { |n| n.to_sym }.uniq
names = names.find_all { |n|