Hstore column integration with simple_form in Rails 4

Is there a good way to integrate hstore with simple_form ?

I just can't find a way to achieve this. I have a column called widget_locations and I would like to store :left_area1, :mid_area1, :left_area2, :mid_area2, :right_area2 as keys and values ​​as nested hashes, so they look like this:

 {:left_area1 => {:video_id => 1, :presentation_id => 3}, :mid_area1 => {:chat_id => 1, :presentation_id => 5}, :left_area2, :mid_area2, :right_area2} 

Is there a better way to achieve this in simple_form?

+7
ruby ruby-on-rails ruby-on-rails-4 simple-form hstore
source share
1 answer

You can do something like this

 <%= f.simple_fields_for :widget_locations do |location| %> <%= location.input :left_area1, :input_html => { :value => <value> } %> <%= location.input :mid_area1, :input_html => { :value => <value> } %> <% end %> 
+8
source share

All Articles