Skip to content

Commit

Permalink
we have a method for this, so let's use it
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jan 5, 2011
1 parent e468a62 commit 8bdc191
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -29,7 +29,7 @@ def insert_record(record, force = true, validate = true)
if @reflection.options[:insert_sql]
@owner.connection.insert(interpolate_sql(@reflection.options[:insert_sql], record))
else
relation = Arel::Table.new(@reflection.options[:join_table])
relation = join_table
timestamps = record_timestamp_columns(record)
timezone = record.send(:current_time_from_proper_timezone) if timestamps.any?

Expand Down Expand Up @@ -59,7 +59,7 @@ def delete_records(records)
if sql = @reflection.options[:delete_sql]
records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) }
else
relation = Arel::Table.new(@reflection.options[:join_table])
relation = join_table
stmt = relation.where(relation[@reflection.foreign_key].eq(@owner.id).
and(relation[@reflection.association_foreign_key].in(records.map { |x| x.id }.compact))
).compile_delete
Expand Down

0 comments on commit 8bdc191

Please sign in to comment.