Forum: Ruby on Rails combo box problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
664cbcec154627ede707f66602054321?d=identicon&s=25 Cezar (Guest)
on 2007-05-10 18:11

1st of all, my english is bad, and i'm new to RoR, so accept my
apologies from start.
I need two combo-boxes populated from two tables that will act as
filters for a product list. I've already read some examples and
tutorials, but it seems that I'm still stuck in the problem.

Files :

the Controller for Products is called admin_product. the list method
takes all the products from the db_table called products and displays
the trick is to have two combo-boxes, 1st populated with the
parent_category_name from the parent_categories table, and the second
populated with category_name from the categories table. the default
value in the combo-boxes should be "- Select a parent category -" and "
- Select a category -".
When a option from the combo boxes is selected, the page should reload,
displaying only the products that have the parent_category_id or the
category_id that was selected. and also, if a parent_category is
selected, the second combo box shoul display only the categories with
the parent_category_id that was selected in the first combo-box. I think
that the ajax example with state/county/city it's not suitable, beacause
the products list might be paginated. If I'm wrong please correct me.

Thank you for spendig this much time reading all this stuff and also for
any hints and code snippets that I can use.

All my respect,
664cbcec154627ede707f66602054321?d=identicon&s=25 Cezar (Guest)
on 2007-05-11 07:19

 the effect could be seen here ;

when you select the subcategories : size in inch the list gets

All my respect,
664cbcec154627ede707f66602054321?d=identicon&s=25 Cezar (Guest)
on 2007-05-11 17:40

 I've wrote in the list.rhtml this piece of code
        collection_select(:categories, :id, @categories, :id,
          options = {:prompt => '- Select Parent Category -'},
          html_options = {:onChange => "remote_function :url =>
{:controller => 'admin_product', :action => 'list'}, :with =>

but it's not working. Any ideas ?
1st of all, prompt should put '- Select Parent Category -' in the
options, and it's not working,
2nd of all, if i do collection_select(:categories, :category_name,
@categories, :id, :category_name,
it says

undefined method `category_name' for #<Array:0x3525f8c>

I've got 2 days now sience i'm stuck with this problem at my diploma
All my respect,
This topic is locked and can not be replied to.