On Friday, August 11, 2006, at 2:50 PM, John Butler
wrote:>Hi,
>
>I have a table similar structure below.
>
>id name position page
>1 name1 1 1
>2 name2 2 1
>3 name3 3 1
>4 name4 1 1
>5 name5 1 1
>6 name6 1 2
>
>What i want is to select all the items for a given page number grouped
>by pos and displayed in a view using a loop like:
>
>display position number, number of records
>for how many records have the same position number
> output the name
>loop
>
>for for example if i wanted page 1 i would get the following output:
>
>postion 1, 3 records
>name1
>name5
>name6
>
>position 2, 1 record
>name2
>
>position 3, 1 record
>name3
>
>is it possible to get all this information in 1 query and is it possible
>to display in 1 loop.
>
>could you please provide an example to get me started please.
http://weblog.rubyonrails.org/2006/03/01/
new-in-rails-enumerable-group_by-and-array-in_groups_of/
--
Posted with http://DevLists.com. Sign up and save your mailbox.