Rails 3.1 - Dynamic Select Menus

I've followed and am using the Dynamic Select Menus as show in the revised Railscast (episode #88) to select Primary Genre and an associated Sub-Genre. Everything seemed to be working fine but i've now noticed that certain primary genres aren't pulling through their sub-genres. It seems that a Genre with a space in it's name is stopping things working. In the Railscast example I can't see any reference to handling this. Can anyone suggest a fix for this? I imagine it's a case of doing some kind of parsing, but not sure where to start with this.

The Railscast is here http://railscasts.com/episodes/88-dynamic-select-menus-revised I've followed it exactly. The only difference is I have Primary Genre/Sub-Genre like:

Rock / Punk Rock Rock / Indie Rock Rock / Hard Rock

Dance & Electronic / Techno Dance & Electronic / Drum & Bass Dance & Electronic / Electronica

Rock selects work fine, Dance & Electronic do not.

Any ideas?


Sounds like maybe you missed the step about escaping the text in the first select menu?

country = $('#person_country_id :selected').text()
escaped_country = country.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')

Check out the last section: http://railscasts.com/episodes/88-dynamic-select-menus-revised?view=asciicast

Need Your Help

Ruby: Difference between these two?

ruby printing coding-style

I was wondering what the difference between print x and print "#{x}", in Ruby was. Does it really matter which one we use?