]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/composite_primary_keys-2.2.2/lib/composite_primary_keys/reflection.rb
Present "too many pending traces" message as a warning box
[rails.git] / vendor / gems / composite_primary_keys-2.2.2 / lib / composite_primary_keys / reflection.rb
1 module ActiveRecord
2   module Reflection
3     class AssociationReflection
4       def primary_key_name
5         return @primary_key_name if @primary_key_name
6         case
7           when macro == :belongs_to
8             @primary_key_name = options[:foreign_key] || class_name.foreign_key
9           when options[:as]
10             @primary_key_name = options[:foreign_key] || "#{options[:as]}_id"
11           else
12             @primary_key_name = options[:foreign_key] || active_record.name.foreign_key
13         end
14         @primary_key_name = @primary_key_name.to_composite_keys.to_s if @primary_key_name.is_a? Array
15         @primary_key_name
16       end
17     end
18   end
19 end