I'm having an issue with an association. I've got an Employee model that belongs_to a Role model. When I try to display the association, I get the full array displayed back.
Here's the show action from my Employee controller. As you can see, I've tried a few different methods to make the proper association in the first place:
def show
@employee = Employee.find(params[:id])
# @role = Role.where(:id => @employee)
# @role = Role.find_by_sql("select roles.role_title from roles where roles.id in (select role_id from employees where role_id='1')")
@role = Role.where(id: @employee)
end
And here's the view:
<p>
<strong>Role:</strong>
<%= @role.each do |r|
r.role_title
end %>
</p>
My output comes back as:
Role: [#<Role id: 3, role_title: "Support Engineer", created_at: "2014-08-20 16:09:22", updated_at: "2014-08-20 16:09:22">]
What am I missing here?