<% @articles.each do |article| %>
<tr>
<td align="center"><%= article.comments_count %></td>
</tr>
<% end %>
undefined method `comments_count' for #<Article:0x007fb51fb001b8>
Did you mean? comments
Hi Syed,
From Schema Conventions section:
There are also some optional column names that will add additional features to Active Record instances
It means that if you add columns (using migration) that have names following the naming conventions, you’ll get that feature.
The <relationship_name>_count
convention is used for counter_cache
option of belongs_to
, which you can read about more here: http://guides.rubyonrails.org/association_basics.html#options-for-belongs-to
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Documentation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-docs+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-docs@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-docs.
For more options, visit https://groups.google.com/d/optout.