ruby on rails 3 - Jquery datepicker date values does not included into database -
date values not included in database
here code jquery datepicker
j$(function() { j$( ".datepicker" ).datepicker();});
and form is
<%= form_for(@leave) |f| %> <%= f.label :start_date %> <%= f.datepicker :start_date , class: 'form-control' %> <%= f.label :start_session %> <%= f.select :start_session, options_for_select([['fullday'],['forenoon'],['afternoon']]) %> <%= f.label :end_date %> <%= f.datepicker :end_date, class: 'form-control' %> <%= f.label :end_session%> <%= f.select :end_session, options_for_select([['fullday'],['forenoon'],['afternoon']]) %> <%= f.label :types %> <%= f.select :typeof, options_for_select([['personal'],['vacation']]) %> <%= f.label :no_of_days %> <%= f.text_field :no_of_days, class: 'form-control' %> <%= f.label :reason %> <%= f.text_area :reason_for_leave, class: 'form-control' %> <%= f.submit "apply", class: "btn btn-primary" %> <% end %>
in controller
def create @leave = leave.new(params[:leave]) respond_to |format| if @leave.save format.html { redirect_to @leave, notice: 'user created.' } format.json { render json: @leave, status: :created, location: @leave } else format.html { render action: "apply" } format.json { render json: @leave.errors, status: :unprocessable_entity } end end
end
and problem not include values column "start_date" , "end_date" here log
parameters: {"utf8"=>"✓", "authenticity_token"=>"sneug2zg76vj8shhbqsv6e3unirhav/tdsf8hxdg1xq=", " leave"=>{"start_date"=>"11/28/2014", "start_session"=>"fullday", "end_date"=>"11/29/2014", "end_ses sion"=>"fullday", "typeof"=>"personal", "no_of_days"=>"2", "reason_for_leave"=>"nothing sss"}, "com mit"=>"apply"} (0.1ms) begin sql (0.4ms) insert "leaves" ("approved", "authorize", "cancel_request", "cancelled", "creat ed_at", "end_date", "end_session", "no_of_days", "reason_for_leave", "reject_reason", "start_date", "start_session", "typeof", "updated_at") values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12 , $13, $14) returning "id" [["approved", nil], ["authorize", nil], ["cancel_request", nil], ["canc elled", nil], ["created_at", thu, 27 nov 2014 13:06:25 ist +05:30], ["end_date", nil], ["end_sessio n", "fullday"], ["no_of_days", 2.0], ["reason_for_leave", "nothing sss"], ["reject_reason", nil], [ "start_date", nil], ["start_session", "fullday"], ["typeof", "personal"], ["updated_at", thu, 27 no v 2014 13:06:25 ist +05:30]] (1.1ms) commit
the columns stored nil, how fix issue?
use id of html control preceded #, this:
$("#idcurrentfrom").datepicker();
Comments
Post a Comment