refactor your collection options into a helper method 

def my_options
  [
   {id:"daily",      label: "daily"}, 
   {id: "weekly",    label: "weekly"}, 
   {id: "14 days",   label: "14days"}, 
   {id: "30 days",   label: "30days"},
   {id: "immediate", label: "immediate"},
   {id: "off",       label: "off"}
  ]
end


  
Then you can use it with simple_forms helpers, value_method and 
label_method 


= simple_form_for @alert do |f|
  .field= f.input :alertFrequency, label: "Alert Frequency", collection: 
my_options, value_method: :id, label_method: :label



Also note camel case is not rails' convention for naming 

On Tuesday, March 10, 2015 at 10:40:09 AM UTC-5, Loha wrote:
>
> Hi folks, i'm new to haml and can't get the select_tag working.  I adapted 
> the following from an example but I can't get it to work.  The form has 
> many text fields and checkboxes working.  The variable is :alertFrequency, 
> database type string. i'm using rails 4. Any assistance appreciated.
>
> = simple_form_for @alert do |f|
>   .field
>     = f.label "Alert Frequency"
>     = select_tag :alertFrequency, options_for_select()
>

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to haml+unsubscr...@googlegroups.com.
To post to this group, send email to haml@googlegroups.com.
Visit this group at http://groups.google.com/group/haml.
For more options, visit https://groups.google.com/d/optout.

Reply via email to