Topic: Select field values with two words

Is there a way to populate a select field with options that consist of two words without using an underscore?

This is what I've got and I'd like to go with 'adventure racing' and 'mountain biking' instead of 'adventure_racing' and 'mountain_biking'.

<%= select(:event, :event_type, %w{ Adventure_Racing Cycling Cyclocross Duathlon Marathon Mountain_Biking Running Triathlon Other }) %>

Re: Select field values with two words

Yep, the %w{} syntax thing is just a shortcut for generating an array of single-word strings. You can switch to a real array if you need something else:

['Adventure Racing', 'Cycling', 'Cyclocross', 'Duathlon', 'Marathon', 'Mountain Biking', 'Running', 'Triathlon', 'Other']

Railscasts - Free Ruby on Rails Screencasts

Re: Select field values with two words

PERFECT. Thanks so much. I got that other technique by cutting and pasting :-)