提交 9863d8a5 编写于 作者: J Jon Leighton 提交者: Aaron Patterson

Remove unnecessary overloaded methods create, create! and create_record from...

Remove unnecessary overloaded methods create, create! and create_record from HasAndBelongsToManyAssociation
上级 7f5fcc07
......@@ -2,14 +2,6 @@ module ActiveRecord
# = Active Record Has And Belongs To Many Association
module Associations
class HasAndBelongsToManyAssociation < AssociationCollection #:nodoc:
def create(attributes = {})
create_record(attributes) { |record| insert_record(record) }
end
def create!(attributes = {})
create_record(attributes) { |record| insert_record(record, true) }
end
def columns
@reflection.columns(@reflection.options[:join_table], "#{@reflection.options[:join_table]} Columns")
end
......@@ -109,16 +101,6 @@ def finding_with_ambiguous_select?(select_clause)
end
private
def create_record(attributes, &block)
# Can't use Base.create because the foreign key may be a protected attribute.
ensure_owner_is_persisted!
if attributes.is_a?(Array)
attributes.collect { |attr| create(attr) }
else
build_record(attributes, &block)
end
end
def record_timestamp_columns(record)
if record.record_timestamps
record.send(:all_timestamp_attributes).map { |x| x.to_s }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册