# HABTM and has\_many through only work in one direction

**URL:** <https://www.ruby-forum.com/t/habtm-and-has-many-through-only-work-in-one-direction/116955>\
**Category:** Rails\
**Created:** [October 11, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/habtm-and-has-many-through-only-work-in-one-direction/116955 "2007-10-11T17:16:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [October 11, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/habtm-and-has-many-through-only-work-in-one-direction/116955/1 "2007-10-11T17:16:47Z")

</div>

I have two models that have a habtm relationship and it only seems to  
be working in one direction.

The two models are “recipe” and “msn\_lifestyles\_feed” with a join  
table called “msn\_lifestyles\_feeds\_recipes”

the tables for msn\_lifestyles\_feed and msn\_lifestyles\_feeds\_recipes  
are in the same database and the recipe table is in a completely  
different database.

When I create a recipe object, it works fine and I can see all the  
feeds that it’s a part of but when I create a feed object and try to  
access all its recipes I get an error saying:

OLE error code:80040E37 in Microsoft OLE DB Provider for SQL Server  
Invalid object name ‘dbo.msn\_lifestyles\_feeds\_recipes’

I’ve also tried this using has\_many :through and I get the same error.  
Any help on this would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![blim8183](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9bcb4/32.png) [@blim8183](https://www.ruby-forum.com/u/blim8183)\
**Post date:** [October 11, 2007, 5:27pm UTC](https://www.ruby-forum.com/t/habtm-and-has-many-through-only-work-in-one-direction/116955/2 "2007-10-11T17:27:20Z")

</div>

Nm, found the solution after two days of pounding my head against my  
desk.

It turned out the problem had to do with the use of two different  
databases.
