Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prefer #foreign_key to #primary_key_name when possible for Associatio…

…nMatcher#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: #9
  • Loading branch information...
commit 6b4035c11783a0588e78d3705bb9425b9b5f45b8 1 parent 574461c
@joelmoss joelmoss authored jasonm committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/shoulda/matchers/active_record/association_matcher.rb
View
2  lib/shoulda/matchers/active_record/association_matcher.rb
@@ -191,7 +191,7 @@ def associated_class
end
def foreign_key
- reflection.primary_key_name
+ reflection.respond_to?(:foreign_key) ? reflection.foreign_key : reflection.primary_key_name
end
def through?

9 comments on commit 6b4035c

@crankharder

Any way this can get released?... It's december and I'm still manually changing this line to remove deprecation warnings. :(

@flackou

+1 for this fix release. Please !

@chip

+1

@thermistor

+1 Please

@3den

+1

@gabebw
Owner

Isn't this in 1.0.0?

@joshuaclayton

@gabebw yes, it is.

@3den

@gabebw @joshuaclayton the problem is because shoulda.gemspec still loading old version of shoulda matchers https://github.com/thoughtbot/shoulda/blob/master/shoulda.gemspec

@3den

I sent a PR to fix this thoughtbot/shoulda#198

Please sign in to comment.
Something went wrong with that request. Please try again.