# Objects returned from JOINS

**URL:** <https://www.ruby-forum.com/t/objects-returned-from-joins/108149>\
**Category:** Rails\
**Created:** [June 29, 2007, 1:15pm UTC](https://www.ruby-forum.com/t/objects-returned-from-joins/108149 "2007-06-29T13:15:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GPB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@GPB](https://www.ruby-forum.com/u/GPB)\
**Post date:** [June 29, 2007, 1:15pm UTC](https://www.ruby-forum.com/t/objects-returned-from-joins/108149/1 "2007-06-29T13:15:10Z")

</div>

Hello…

This is my first Ruby on Rails application so please bear with me.

I have a Find that looks like this:

Record.find(:all,  
:select =\> “records.id, records.firstname, records.lastname,  
cities.city, departments.department, countries.country”,  
:order =\> column\_name,  
:joins =\> “JOIN cities ON cities.id = city\_id JOIN countries ON  
countries.id = country\_id JOIN departments ON departments.id =  
department\_id” )

An it return the following objects:

- !ruby/object:Record  
attributes:  
department: Administration  
city: Lima  
country: Peru  
lastname: Perez  
firstname: Pablo  
id: “5”
- !ruby/object:Record  
attributes:  
department: Information Technology  
city: Lima  
country: Peru  
lastname: Rosas  
firstname: Jaime  
id: “2”

Up to this point all is good.

However, when I try to output these values doing this:

```
<td><%=h record.firstname %></td>
<td><%=h record.lastname %></td>
<td><%=h record.city %></td>
<td><%=h record.country %></td>
<td><%=h record.department %></td>

```

The fields that come from the Records table are displayed. However,  
the fields for City, Country and Department come out as blanks, even  
though in the debug output it shows they contain data.

What am I doing wrong?!

Thank you in advance.

GPB
