Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Cleanup.
- Loading branch information
Gabe Berke-Williams
committed
Mar 23, 2012
1 parent
c10cf34
commit 41bccc8
Showing
3 changed files
with
20 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This assumes that your join table exists in the "primary" rails database. It is possible to point models at an alternate database. It's also possible to configure a HABTM relationship where all three tables exists in a completely different database (in which case this matcher fails). Using this line of code, we can fix the problem:
model_class.connection.tables.include?(join_table.to_s)
This uses the model's connection to determine where the join table is located. I have no problem making this change, but honestly, I'm not sure how to write a test for it? The change is somewhat benign and all the existing tests should continue to pass. Any guidance for me?