For some weird reason, associations in my list view is not working consistently. In my models I have:
Class Restaurant < ActiveRecord::Base
has_many :menus
Class Menu < ActiveRecord::Base
Belongs_to :restaurant
In my controller I have:
def list
@menus = Menu.order("menus.id ASC")
end
In my view I have:
<% = menus.each do |menu| %>
<h4><%= menu.restaurant.name %></h4>
<% end %>
I am getting undefined method “name” . name is a column in the restaurant table.
However, it works in my show view when I use < %= @menu.restaurant.name % >
with no problem.
I am using rails 3.2.9 and ruby 1.9.3