I am working on a project and currently working on one of the views which is a page of different categories. Everything is rendering correctly however it\'s also putting the db
Yes, fix is:
<% @categories.each do |c| %>
<%= image_tag c.image, :class => "cat" %>
<%= c.title %>
<% end %>
Look I removed =
from this <%=
.. In the below line :
<% @categories.each do |c| %>
#each
method returns the collection after it completed its iterations. And due to this <%=
, the return value of each
which is @categories
printed back. But if you use <%..
only, all above things will happen, but it wouldn't print back the object @categories
.