Rails Array not Saving to DB -


i have table check boxes in first column , list of plan names in column. want able check boxes next listings, click form_submit button, , have checked listings save array column in database.

i have table functioning array column - can manually enter array column (using db management service called adminium). try update array values through application, clears array values , doesn't add selected items.

view

<%= form_tag :action => 'planselection', :id => @current_plan.id, :method => :put  %>  <%= submit_tag "add selected plans quote" %>    <table id="dt" class="table table-striped table-hover">   <thead>     <tr>         <th></th>             <th>plan name</th>       <th>carrier</th>       <th>plan type</th>       <th>deductible</th>       <th>monthly premium</th>         <th></th>     </tr>   </thead>    <tbody>     <% @benefit_details.where(:plan_year => @current_plan.plan_year).each |benefit_detail| %>        <tr>         <td><%= check_box_tag "plan_selection[]", benefit_detail.plan_name %></td>         <td><%= benefit_detail.plan_name %></td>          <td><%= benefit_detail.carrier %></td>         <td><%= benefit_detail.plan_type %></td>                 <td><%= benefit_detail.deductible %></td>                 <td><% @agetest = agefactor.where("carrier = ? , age = ?", @carrier, @age).pluck(:age_factor) %></td>                  <td>                         <a href="#" class="btn btn-circle btn-default btn-xs ">                         <i class="fa fa-search"></i></a>                         <a href="#" class="btn btn-circle btn-default btn-xs ">                         <i class="fa fa-bar-chart-o"></i></a>                         <a href="#" class="btn btn-circle btn-default btn-xs ">                         <i class="icon-plus"></i></a>                 </td>         </tr>     <% end %>   </tbody> </table>  <% end %> 

controller

  def planselection     # todo add plan selections current plan      @current_plan.update(plan_selection: "plan_selection")     #@current_plan.update("plan_selection=?", :planselection)      redirect_to :back   end  

terminal output

started post "/current_plans/planselection?id=12&method=put" 66.186.164.130 @ 2015-07-01 17:46:32 +0000 processing currentplanscontroller#planselection html   parameters: {"utf8"=>"✓", "authenticity_token"=>"aewaorqwzbskkelbdyj3=", "commit"=>"add selected plans quote", "dt_length"=>"10", "plan_selection"=>["silver hmo 2,000 - md3487/rx1028", "silver hmo 2,000 - md3487/rx1022", "silver hmo 2,500 - md3486/rx1021", "silver hmo 2,500 - md3486/rx1022"], "id"=>"12", "method"=>"put"}   currentplan load (30.5ms)  select  "current_plans".* "current_plans"  "current_plans"."id" = $1 limit 1  [["id", 12]]    (30.5ms)  begin    (30.3ms)  commit 

try -> @current_plan.update(plan_selection: params[:plan_selection])


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -