Question

Does anybody know any simple_form or formtastic input for hstore? I tried to search for any input but I didn't find any yet... It seems that the hstore field type is not yet supported...

I would need it...

Était-ce utile?

La solution

You may use like this for input as 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 %>

Autres conseils

Its not supported directly. But you can do something like this

<%= f.simple_fields_for :settings do |setting| %>
    <%= setting.input :color, :input_html => { :value => <value> } %>
    <%= setting.input :height, :input_html => { :value => <value> } %>
<% end %>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top