I'm setting up a music catalogue to learn my way around RoR. In
index.html.erb I would like to show the band name instead of the id.
What is the proper way to do this?

# records.rb
class Record < ActiveRecord::Base
  belongs_to :band;
end

# bands.rb
class Band < ActiveRecord::Base
  has_many :records
end

# views/records/index.html.erb
...
<% @records.each do |record| %>
  <tr>
    <td><%=h record.band.name %></td>
    <td><%=h record.title %></td>
    <td><%=h record.description %></td>
...

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to