method

insert_record

Importance_0
v3.1.0 - Show latest stable - 0 notes - Class: ActiveRecord::Associations::HasAndBelongsToManyAssociation
insert_record(record, validate = true, raise = false) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb, line 12
      def insert_record(record, validate = true, raise = false)
        if record.new_record?
          if raise
            record.save!(:validate => validate)
          else
            return unless record.save(:validate => validate)
          end
        end

        if options[:insert_sql]
          owner.connection.insert(interpolate(options[:insert_sql], record))
        else
          stmt = join_table.compile_insert(
            join_table[reflection.foreign_key]             => owner.id,
            join_table[reflection.association_foreign_key] => record.id
          )

          owner.connection.insert stmt
        end

        record
      end
Register or log in to add new notes.