app/helpers/application_helper.rb
# improved Rails "select" helper with pre-selected value
# default value is original method value
improved Rails "select" helper with pre-selected value
default value is original method value
improved Rails " select " helper with pre - selected value default value is original method value
def select_with_default(form, method, choices, default=nil, options = {}, html_options = {})
    choices.blank? and return 
    default ||= form.object.send(method).to_s
    form.select( method, options_for_select(choices, default), options, html_options )
  end
def select_with_default ( form , method , choices , default = nil , options = { } , html_options = { } ) choices . blank? and return default ||= form . object . send ( method ) . to_s form . select ( method , options_for_select ( choices , default ) , options , html_options ) end
improved Rails "select" helper with pre-selected value
default value is original method value
improved Rails " select " helper with pre - selected value default value is original method value
# do nothing.
form
<not_specific>
method
<not_specific>
choices
<not_specific>
default
<not_specific>
options
<not_specific>
html_options
<not_specific>