My problem is that I try to invoke an association to a table. I get the ID number but want to get a different field from it. when will this problem up Model
class Category < ActiveRecord::Base
has_many :suppliers
end class Supplier < ActiveRecord::Base belongs_to :categories end
class Supplier < ActiveRecord::Base
belongs_to :categories
end
主计长
def index
@suppliers = Supplier.all
end
View :
<% @suppliers.each do |s|%>
<td><%= s.name %></td>
<td><%= s.inspect %></td>
<% s.categories.each do |c|%>
<td><%= c.inspect %></td>
<%end%>
<% end %>
errormesseage : uninitialized constant Supplier::Categories