Objects returned from JOINS

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