jquery - Saving date from datepicker -


in form i'm using datepicker plugin. works fine, , form code looks this:

= simple_form_for @person |f|     = f.input :born, input_html: {class: "datepicker"}, as: :string     = f.input :died, input_html: {class: "datepicker"}, as: :string     = f.submit 

however, params in form of string, "2015/02/04" , not saved in database. classic input params competely different. how can make these params save database?

your date string looks 2015/02/04 default format of datepicker plugin, save database need change 2015-02-04 format. need in action

params[:born] = params[:born].gsub("/", "-") 

or

you need pass option when initializing datepicker plugin, give below

$( ".datepicker" ).datepicker({       dateformat: 'dd-mm-yyyy' }); 

hope helps!


Comments

Popular posts from this blog

html - height not adding height to a empty div -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

python - Robot Framework location and name of keyword -