Steve Castaneda wrote: > Hi everyone! :) > > I'm currently accomplishing what I want, but I'd like to clean it up a > bit. I've placed the following items in an array (please excuse my lack > of proper syntax): > > @widgets = > > [1, red] > [2, blue] > [3, red] > [4, blue] > > I'd like to learn a way to search through the @widgets variable an > separate the widgets, so that I could have: > > @blue_widgets = > > [2, blue] > [4, blue] > > @red_widgets = > > [1, red] > [4, blue] > > ...after performing a query on @widgets. > > I'm accomplishing this now by doing multiple queries to my database, but > I'm sure there's a way to do it by just doing one query, and then > separating the data
Look at Array#partition. > into different variables in my controller. Would > that be the best place to do this? It might be better in the model. You shouldn't have much logic in the controller. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- Posted via http://www.ruby-forum.com/.
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.