Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use association.foreign_key istead of association.primary_key_name to…

… avoid a warning below which says

the method would be removed from Rails 3.2.

DEPRECATION WARNING: primary_key_name is deprecated and will be removed from Rails 3.2 (use foreign_key instead). (called from block (2 levels) in <top (required)> at /path/to/myapp/spec/spec_helper.rb:<line_num>

object.destroy! was stated at /path/to/myapp/spec/spec_helper.rb:<line_num>
  • Loading branch information...
commit 7c575faad07325910ab3a4118e3450b925d5b6a9 1 parent 8776a06
koji authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/rails3_acts_as_paranoid.rb
View
6 lib/rails3_acts_as_paranoid.rb
@@ -154,12 +154,12 @@ def recover_dependent_associations(window, options)
end
elsif association.macro == :has_one && association.klass.paranoid?
association.klass.unscoped do
- object = association.klass.paranoid_deleted_around_time(paranoid_value, window).send('find_by_'+association.primary_key_name, self.id)
+ object = association.klass.paranoid_deleted_around_time(paranoid_value, window).send('find_by_'+association.foreign_key, self.id)
object.recover(options) if object && object.respond_to?(:recover)
end
elsif association.klass.paranoid?
association.klass.unscoped do
- id = self.send(association.primary_key_name)
+ id = self.send(association.foreign_key)
object = association.klass.paranoid_deleted_around_time(paranoid_value, window).find_by_id(id)
object.recover(options) if object && object.respond_to?(:recover)
end
@@ -170,7 +170,7 @@ def recover_dependent_associations(window, options)
def act_on_dependent_destroy_associations
self.class.dependent_associations.each do |association|
if association.collection? && self.send(association.name).paranoid?
- association.klass.with_deleted.instance_eval("find_all_by_#{association.primary_key_name}(#{self.id})").each do |object|
+ association.klass.with_deleted.instance_eval("find_all_by_#{association.foreign_key}(#{self.id})").each do |object|
object.destroy!
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.