Browse files

define foreign_key as an alias of primary_key_name to maintain backwa…

…rd compatibility

Method primary_key_name is now deprecated and the replacement foreign_key is newly
introduced in active_record 3.1.0. While the new method should be used for rails 3.1.x
or later, the old one is still required for rails 3.0.x.
  • Loading branch information...
1 parent 655933a commit d65de64d77f282ee4b23a41e16937df9e5c8525b @codeout codeout committed Sep 24, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/rails3_acts_as_paranoid.rb
@@ -31,6 +31,10 @@ def acts_as_paranoid(options = {})
alias_method :destroy!, :destroy
+ ActiveRecord::Reflection::AssociationReflection.class_eval do
+ alias_method :foreign_key, :primary_key_name unless respond_to?(:foreign_key)
+ end
# Magic!
default_scope where("#{paranoid_column_reference} IS ?", nil)

0 comments on commit d65de64

Please sign in to comment.