lundi 28 janvier 2019

Saving date field as dd/mm/yyyy rails

We have a date_of_birth field of date type in our User model.

When I am trying to save my User object.

u = User.last
u.date_of_birth = "31-03-1987"
u.save

results:

u.date_of_birth
=> Tue, 31 Mar 1987

but If I replace - with /

u.date_of_birth = "31/03/1987"
u.save

results:

u.date_of_birth
=> nil

Question

Is this is a default behaviour?

Rails 3

Postgres

Aucun commentaire:

Enregistrer un commentaire