# Linked table confusion

**URL:** <https://www.ruby-forum.com/t/linked-table-confusion/101706>\
**Category:** Rails\
**Created:** [February 6, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/linked-table-confusion/101706 "2006-02-06T22:29:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 6, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/linked-table-confusion/101706/1 "2006-02-06T22:29:00Z")

</div>

placement.rb  
has\_one :client  
has\_one :case\_manager

client.rb  
belongs\_to :case\_manager  
has\_many :placements

case\_manager.rb  
has\_many :clients  
has\_many :placements

I am trying to create a view file for placements.

I can pull columns from clients table in this view by using…

\<%= @placement.client.wholename %\>

but if I use

\<% @placement.case\_manager.wholename %\>

I get error…

RuntimeError: ERROR C42703 Mcolumn case\_managers.placement\_id does  
not exist Fparse\_func.c L1359 Runknown\_attribute: SELECT \* FROM  
case\_managers WHERE (case\_managers.placement\_id = 4) LIMIT 1

which makes sense in that I don’t have a ‘placement\_id’ column in  
case\_managers table. But case manager has many placments so I did create  
a join table - case\_managers\_placements in which there are 2 fields…  
placement\_id  
case\_manager\_id  
and foreign keys for both fields to their respective tables  
then I inserted 1 record, for the placement with the proper placement\_id  
and case\_manager\_id for the join…

I still get the above error.

How does one work through this situation?

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 7, 2006, 12:29am UTC](https://www.ruby-forum.com/t/linked-table-confusion/101706/2 "2006-02-07T00:29:26Z")

</div>

Craig,

I think you have confused the relationship between placements and  
case\_managers. If its a one-to-many then you shouldn’t be using a  
join table. Just put your foreign table references, case\_manager\_id  
and client\_id, into the placements table.

Then your placement model would be:

placement.rb  
belongs\_to :client  
belongs\_to :case\_manager

Estelle.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 7, 2006, 12:35am UTC](https://www.ruby-forum.com/t/linked-table-confusion/101706/3 "2006-02-07T00:35:35Z")

</div>

Craig,

You might find this tutorial handy…

> **[activerecord\_cheatsheet.pdf](https://www.slash7.com/cheats/activerecord_cheatsheet.pdf)**
>
> 51.59 KB

Estelle.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 7, 2006, 1:21am UTC](https://www.ruby-forum.com/t/linked-table-confusion/101706/4 "2006-02-07T01:21:19Z")

</div>

Estelle (my grandmother’s name), that was brilliant - it solved my  
issues.

Thanks

Craig

and thanks for the link to the mini cheatsheet.
