Submit array elements in a rails form -


i have postage table rate column array type using postgresql. array contains 3 values e.g [1.99, 2.99,5.99]. can't figure out how submit form properly, want display field each element of array.

my current non-working code is;

    = form_for [:admin,@postage] |f|       .field-box         = f.label :name         = f.text_field :name         = f.label "uk"         = text_field_tag "rate[]"         = f.label 'eu'         = text_field_tag "rate[]"         = f.label "rest of world"         = text_field_tag "rate[]" 

the form passed in parameters isn't saved database

parameters: {"utf8"=>"✓", "authenticity_token"=>"xxx=", "postage"=>{"name"=>"item1"}, "rate"=>["1.99","2.99","5.99"], "button"=>"", "id"=>"2"} 

how correctly set form, , order intact?

it looks serializing properly. using rails 4? if so, check permit method in controller. pg array, should this:

params.permit({rate: []}) 

also, recommend changing column name rates. :)


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -