Prefer #foreign_key to #primary_key_name when possible for AssociationMatcher#foreign_key

Fixes deprecation warning added in Rails 3.1:
https://github.com/rails/rails/blob/v3.1.0.beta1/activerecord/lib/active_record/reflection.rb#L201-208

Closes: https://github.com/thoughtbot/shoulda-matchers/pull/9
This commit is contained in:
Joel Moss 2011-05-19 17:18:47 +01:00 committed by Jason Morrison
parent 574461c63a
commit 6b4035c117
1 changed files with 1 additions and 1 deletions

View File

@ -191,7 +191,7 @@ module Shoulda # :nodoc:
end
def foreign_key
reflection.primary_key_name
reflection.respond_to?(:foreign_key) ? reflection.foreign_key : reflection.primary_key_name
end
def through?