Situation
- I have two models cables and status
- Cables belongs to status, and status has many cables
Anywhere that is returning a single record the following code works
@cable.status.stat #where stat is one of the columns in status
However since my index returns All cables, when I try to access them from view by doing the following
<% @cables.each do |cable| %> <td><%= cable.Cable_Hex %></td> <td><%= cable.status.stat %></td> </tr> <% end %>
I get an error stating that .stat is not recognized. When I remove .stat and leave it as cable.status then I just see an address.
If I try to access the foreign_id then I can see it without a problem. Clearly then associated methods are not readily available in view.
How do I access associated model methods from a view?
--Edit-- Including both Models as requested
Model for Cables
class Cable < ActiveRecord::Base
belongs_to :user, :inverse_of => :cables
belongs_to :status, :inverse_of => :cables
end
Model for Status
class Status < ActiveRecord::Base
has_many :cables, :inverse_of => :statuses
end