Posts [ 10 ]

Topic: DRY collection of a find result

Hello,

I want to extract four instance variables to make them available to a view. My query:

@results = Item.find(:all, :conditions ...)

Now, each item in @results belongs to a category and in the view, they should be separated for better display. So is it better to write 4 find lines or only one as above and collect them ? if you suggest the second way, please help me in coding it!

Re: DRY collection of a find result

Yes, however that will re-sort each collection right? What I'm looking to do is only resort one. eg. I have a list of projects grouped by division. Now I want to resort the projects from division X by some other attribute. But leave the other ones sorted as they already are. I've got them listed ok. But when I go to sort is where I'm looking for some guidance.

Re: DRY collection of a find result

hmmm... al these suggestions look like they would still apply globally? Maybe I'm missing something or not being clear.

I have a model Projects that has a bunch of fields (including belonging to Division). I grab all the projects and group them by Division and list them in said groups. Each group is sorted by a default order I declare when I do the find/group_by. I'd *like* to be able to re-sort ONE of the groups by a different attribute than the default (say by a column header link).

I can do it where I re-sort all the groups , but I'd like to see how to only update one of em. Hopefully, that clears up what I'm tryin to do?