module ActiveRecord module Associations class HasAndBelongsToManyAssociation def create(attributes = {}) # Can't use Base.create since the foreign key may be a protected attribute. if attributes.is_a?(Array) attributes.collect { |attr| create(attr) } else record = build(attributes) insert_record(record) unless @owner.new_record? record end end end end end