【问题标题】:simple_form or formtastic Input type for hstore用于 hstore 的 simple_form 或 formtastic 输入类型
【发布时间】:2014-01-28 14:45:34
【问题描述】:

有人知道hstore 的simple_form 或formtastic 输入吗? 我试图搜索任何输入,但我还没有找到任何... 似乎尚不支持 hstore 字段类型...

我需要它...

【问题讨论】:

    标签: ruby-on-rails simple-form formtastic hstore


    【解决方案1】:

    您可以像这样将输入用作 hstore:

     <%= simple_form_for @product do |f| %>
       <%= f.simple_fields_for :attributes do |d| %>
           <% f.object.attributes.try(:each) do |key, value| %>
              <%= d.input key, :input_html => {:value => value } %>
           <% end %>
       <% end %>
    <% end %>
    

    【讨论】:

      【解决方案2】:

      不直接支持。但是你可以做这样的事情

      <%= f.simple_fields_for :settings do |setting| %>
          <%= setting.input :color, :input_html => { :value => <value> } %>
          <%= setting.input :height, :input_html => { :value => <value> } %>
      <% end %>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-23
        相关资源
        最近更新 更多