Hello,
I’m just starting out with RoR and have been playing around with making
my own blog using RoR as a quick way of getting my feet wet. RoR is neat
isn’t it! Liking the link_to etc helpers, seems such a good way of doing
things.
Anyway, my little problem goes like this:
I want a link that says Comments (#of comments), for instance “Comments
(2)”.
To make my link without the number, I have used:
<%= link_to ‘Comments’, {:action => ‘show’, :id => post, :anchor =>
‘comments’}, :class => ‘comments’ %>
And I know that:
<%= post.comments.count %>
tells me how many comments are for this post. (I’m looping through a
load, so the :id exists etc.)
How do I do this?
<%= link_to ‘Comments (post.comments.count)’, {:action => ‘show’, :id =>
post, :anchor => ‘comments’}, :class => ‘comments’ %>
so that the code actually executes? I can’t work it out!
Thanks!