Last Updated: February 25, 2016
· shinn

hstore and Rails Form

Working with hstore in Rails is fun; however when using it with Rails form builder, it does not repopulate the data because of its key and value properties. Fortunately this can be solved easily by using OpenStruct.

<%= f.fields_for :parts, do |p| %>
    <%= p.label :keyboard %>
    <%= p.text_field :keyboard %>
<% end %>