views:

114

answers:

1

Hi,

I have created the following select using the option_groups_from_collection_for_select form helper in Rails as part of a search feature.

All Categories Garden Accessories Gardens Random Sheds Playsets

The problem is, I want a user to be able to search all of the "Garden" sub-categories at once, but as "Garden" is a label, this does not work, it forces the user to pick one of the sub-categories.

One idea is to somehow be able to add a All Garden tag within the optgroup, but not sure how to inject this into the list.

Any ideas would be appreciated!! Thanks

My search form has no room to add a second sub-category select box.

A: 

I figured this out,

In the method I am using to get the child-categories for the optgroup, I just append the current model / category to the array of child categories returned from the AR find call and it works a treat.

.unshift(self.dup)

Hope this helps someone.

Jason