Hi i have the following code:
class Color < ActiveRecord::Base
has_many :products
end
class Product < ActiveRecord::Base
belongs_to :color
end
Products index view:
<% @products.each do |product| %>
<%=h product.color_id %> |
<%= link_to 'Show', product %> |
<%= link_to 'Edit', edit_product_path(product) %> |
<%= link_to 'Destroy', product, :confirm => 'Are you
sure?', :method => :delete %> |
<% end %>
How do I get this:
<%=h product.color_id %> | to display the
name of the color instead of the id?
On 13 February 2010 17:56, andkjaer [email protected] wrote:
How do I get this: <%=h product.color_id %> to display the
name of the color instead of the id?
<%=h product.color.name %>