Using ActiveRecord::Base.connection is presumptuous. You must infer the 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.

This commit is contained in:
Karle Durante 2012-09-18 15:31:17 -04:00 committed by Jason Draper
parent f6edb1589f
commit 41c763d276
1 changed files with 1 additions and 1 deletions

View File

@ -243,7 +243,7 @@ module Shoulda # :nodoc:
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)
true
else
@missing = "join table #{join_table} doesn't exist"