Rails 5 ActiveRecord Update Serialized Array in Form -


i have field serialized array. it's loaded model , accessed in form:

class site < applicationrecord   serialize :steps, array end   <table class="listing" summary="site list">     <tr class="header">       <th>name</th>       <th>step 1</th>       <th>step 2</th>       <th>step 3</th>       <th>actions</th>     </tr>     <% @sites.each |site| %>     <tr>       <td><%= site.name %></td>       <% site.steps.each |step| %>       <td><%= step %></td>       <% end %>       <td class="actions">         <%= link_to("show", site_path(site), :class => 'action show') %>         <%= link_to("edit", edit_site_path(site), :class => 'action edit') %>         <%= link_to("delete", delete_site_path(site), :class => 'action delete') %>       </td>     </tr>     <% end %>   </table> 

i'm trying update edit form can edit each "step" in array.

 <%= form_for(@site) |f| %>      <table summary="site form fields">       <tr>         <th>name</th>         <td><%= f.text_field(:name) %></td>       </tr>       <% a=1 %>       <% @site.steps.each |step| %>       <tr>       <th>step <%= %>       <td><%= text_field :site, :steps, :value => step %></td>       <% += 1 %>       </tr>       <% end %>     </table>      <div class="form-buttons">       <%= f.submit("update site") %>     </div>    <% end %> 

the edit form displays steps field correctly each individual string in array. however, when attempt submit form following error:

attribute supposed array, string. 

so steps being submitted last entry in array. how can display form correctly , present updated array controller processing?


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -