Rails count and display -
i new rails. have 3 models tickets, tags , comments relationships , working fine.
i want display total number of tickets in ticket index view, don't know why... think easy answer guys...
<%= ticket.count %> says undefined method.
can me or need more informations? thank you!
assuming in ticketcontroller have this:
def index @tickets = ticket.all end
in index
view, display count of tickets, follows:
<%= @tickets.count %> <% @tickets.each |ticket| %> ..... <% end %>
call count
method on collection object @ticket
(array of type activerecord::relation
) , not on ticket
instance of ticket
class.
Comments
Post a Comment