I’m fairly new to rails (only about a month’s experience), so this may be trivial. In my app, if I call
<%= Group.find(:all).each do |g| %>
<p><%= g.name %></p>
<%= end %>
it prints out all of the groups’ names correctly. However, afterwards, it returns all of them (with the hexcodes, and stuff). I figure that’s because .find returns everything you have it iterate over. Anyways – on to my question: Is .find the wrong method, or how do I go about iterating over every Group, without returning them afterwards?
I would appreciate any help or insight you all have.
Thanks!
I’m guessing you’re doing something like
That would print the return value of the whole statement. Instead, do this
That wouldn’t print the returned value.
Sidenote:
Group.find(:all)is the same asGroup.all