Skip to content
Browse files

Using ActiveRecord::Base.connection is presumptuous. You must infer t…

…he home of the join table using the parent model. This allows developers to define HABTM relationships in other databases and still use the 'have_and_belong_to_many' matcher.
  • Loading branch information...
1 parent f6edb15 commit 41c763d27656fd76ed6be567ce9cb063f6ab6696 @karledurante karledurante committed with drapergeek Sep 18, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/shoulda/matchers/active_record/association_matcher.rb
2 lib/shoulda/matchers/active_record/association_matcher.rb
@@ -243,7 +243,7 @@ def conditions_correct?
def join_table_exists?
if @macro != :has_and_belongs_to_many ||
- ::ActiveRecord::Base.connection.tables.include?(join_table)
+ model_class.connection.tables.include?(join_table)
@missing = "join table #{join_table} doesn't exist"

0 comments on commit 41c763d

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