From 7ef3cb6c19abafae66e2f7ead01f558eb4f5da92 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Sun, 2 Nov 2014 12:41:52 -0700 Subject: [PATCH] Fix deprecation warning on Rails 3.2 --- .../active_record/association_matchers/model_reflection.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb b/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb index ec5ea912..0302d389 100644 --- a/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +++ b/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb @@ -48,10 +48,10 @@ module Shoulda def foreign_key if has_and_belongs_to_many_reflection has_and_belongs_to_many_reflection.foreign_key - elsif reflection.respond_to?(:primary_key_name) - reflection.primary_key_name - else + elsif reflection.respond_to?(:foreign_key) reflection.foreign_key + else + reflection.primary_key_name end end