I commonly create helper function to make <select> tags with pre-built options so I can just do something like:
<%=region_select_tag(default_region)%>
to generate a dropdown of values in my views. The helper function already knows the options to choose from. I usually make three different versions of each select helper. For example:
* region_options_for_select(selected=nil, options={}) * region_select_tag(name, selected=nil, options={}, html_options={}) * region_select(object, method, options, html_options={})
This API is meant to mimic the Rails select helpers. It gives me just the options if I want a custom <select> tag, or it can give me the select tag, or it can work of an object and attribute.
I have many of these and I want to dry up my code. For the most part the only difference between all my select helpers is the XXXX_options_for_select() method which actually defines the list. For example here is a following sample implementation: