Hi Everyone?
I have a Rails simple application that has two main models. A person model and a gift model. Gifts belong to people, and people have many gifts.
I am currently (in the people index view) listing all people in the database with the following code:
<% for person in @people %>
<li><%= link_to h(person.name), person %></li>
<% end %>
What I would like to do, is have the number of gifts associated to a person next to their name in brackets. Example:
Danny McC (10)
Is there a built in way of doing this? Such as:
<%= @person.name.count =>
Is this possible?
Thanks,
Danny