Sort the collection in the index.rhtml


i am using rails 1.2.6 please forgive me as this application is live
and i could not find the time to move it to rails 2.0

i have a index.rhtml for items

item has 3 attributes other than id, they are name, category and size

current status =>

inside the index.rhtml

i obviously already display my data as below:

name category size
a mugs L
aa mugs M
abc towels L
bb toothpaste S

what i need now is an additional drop down list that will contain all
possible categories of the products

so if i choose let say, mugs from the drop down list the whole page
can either using ajax to refresh the list to contain just mugs or do a
refresh of the page.

this drop down not only needs to include teh varioous categories but
also the word ‘All’ so that if the user chooses All , the list will
again display all items in database.

Can someone please enlighten me on how to do this?

Thank you.

You mean to say you want to create a dynamic drop down in which if a
category is changed then the other drop down should be filled


I meant that i only want 1 drop down.

depending on what i chose in that drop down list, i will display items
based on drop down.

that drop down will include all possible categories as well as teh
value “All”


if i have just 5 items,

item 1 category is mugs
item 2 category is mugs
item 3 category is towels
item 4 category is towels
item 5 category is cups

if i chose all in that drop down, the page will display items 1 - 5
if i chose mugs in the drop down, the page will display items 1 - 2
if i chose towels in the drop down, the page will display items 3 - 4
if i chose cups in the drop down, the page will display items 5

Please advise.

Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs