In your example you could do the following:
<%
if @categories
for category in @categories %>
<%= link_to “test”, “http://www.rubyonrails.org/” %>
<% end
end
%>
I would like to use the “puts” => but it doesn’t output anything? The =
is working good but I don’t like to open and close %> all the time if I
need to use <%=
One suggestion – to make it look more clean – is that you make sure in
the controller that @categories is not nil (instead of in the view). If
you do that the code in your view could look like this: