Rails 3: f.select - options_for_select

后端 未结 6 1413
你的背包
你的背包 2021-01-31 16:47

I have a form on my Ruby on Rails3 Application with a drop menu, this is my current code for the select option:

<%= f.select :phone_type, options_for_select([         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-31 17:18

    In Rails 4, this approach works well for me.

    <%= f.select :status, options_for_status, {}, prompt: 'Select One' %>
    

    Meanwhile I have defined the options in a helper to keep the clutter out of my view.

    def options_for_status
      [
        ['First Option','first_option'],
        ['Second Option','second_option']
      ]
    end
    

提交回复
热议问题