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, OpenStruct.new(f.object.parts) do |p| %>
<%= p.label :keyboard %>
<%= p.text_field :keyboard %>
<% end %>
Written by shinn
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#