I'm doing fixeddeposit project, in opening account page (i.e.,) in _form. I'm having checkbox to select the deposit amount using javascript. Where deposit amount's datatype is float. It add the value on that page only, when i am trying to hit the submit button it shows the folowing error message
undefined method `to_f' for ["0", "0", "0", "0", "0", "0", "0", "0", "0", "100000", "0", "0"]:Array
** my _form.html.erb**
<tr>
<th><%= f.label :click_your_deposit_amount %></th>
</tr>
<tr>
<td>
<%= f.check_box :depamt, {:multiple => "true"}, 500 %>500
<%= f.check_box :depamt, {:multiple => "true"}, 1000 %>1000
<%= f.check_box :depamt, {:multiple => "true"}, 2000 %>2000
<%= f.check_box :depamt, {:multiple => "true"}, 3000 %>3000
<%= f.check_box :depamt, {:multiple => "true"}, 4000 %>4000
<%= f.check_box :depamt, {:multiple => "true"}, 5000 %>5000
<%= f.check_box :depamt, {:multiple => "true"}, 10000 %>10000
<%= f.check_box :depamt, {:multiple => "true"}, 50000 %>50000
<%= f.check_box :depamt, {:multiple => "true"}, 100000 %>100000
<%= f.check_box :depamt, {:multiple => "true"}, 500000 %>500000
<%= f.check_box :depamt, {:multiple => "true"}, 1000000 %>1000000
</td>
</tr>
<tr>
<td>
<span id="span"></span>
<div>Total Deposit Amount: <span id="amt"> </span></div>
</td>
</tr>
<script>
$('input:checkbox').change(function(){
var total = 0;
$('input:checkbox:checked').each(function(){
total+=parseInt($(this).val());
$('#amt').html(total)
});
});
</script>
here is my controller
fds_controller.rb
class FdsController < ApplicationController
def new
@fd = Fd.new
end
def create
@fd = Fd.new(params[:fd])
if @fd.save
flash[:success] = "FD Account Opened Successfully!"
redirect_to fds_path
else
flash[:error] = "Couldn't Open FD"
render 'new'
end
end
end
I dono how to store the checked values in my database(sqlite3).
Kindly help me to solve this issue.
-Thanks... :)
to_f' for ["0", "0", "0", "0", "0", "0", "0", "0", "0", "100000", "0", "0"]:Array): app/controllers/fds_controller.rb:7:innew' app/controllers/fds_controller.rb:7:in `create'