instance method construct_quoted_owner_attributes

Ruby on Rails 3.0.20

Since v3.0.20 Last seen in v3.0.20

Signature

construct_quoted_owner_attributes(reflection)

Associate attributes pointing to owner, quoted.

Parameters

reflection req
Source
# File activerecord/lib/active_record/associations/through_association_scope.rb, line 31
      def construct_quoted_owner_attributes(reflection)
        if as = reflection.options[:as]
          { "#{as}_id"   => @owner.class.quote_value(
              @owner[reflection.active_record_primary_key],
              reflection.klass.columns_hash["#{as}_id"]),
            "#{as}_type" => reflection.klass.quote_value(
              @owner.class.base_class.name.to_s,
              reflection.klass.columns_hash["#{as}_type"]) }
        elsif reflection.macro == :belongs_to
          { reflection.klass.primary_key => @owner.class.quote_value(@owner[reflection.primary_key_name]) }
        else
          column = @owner.class.columns_hash[reflection.active_record_primary_key]

          { reflection.primary_key_name => @owner.class.quote_value(@owner[reflection.active_record_primary_key], column) }
        end
      end

Defined in activerecord/lib/active_record/associations/through_association_scope.rb line 31 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Associations::ThroughAssociationScope

Type at least 2 characters to search.

↑↓ navigate · open · esc close