0
I have two fields called start_year and end_year, in which I want to save only the year that the user will select and save in the database. But when you save the form that is processed by RAILS, it saves year, month and day.
I wonder if I can save a date type data in Postgres by storing only the year through RAILS.
On the web page and basically as soon as you get the data
That in html.erb the code is like this []
In the database there is a table that would be the one that is the creation of user by.
And in this photo below are the fields that are added to the user table, in which follows the fields start_year and end_year
In case I can not extract only year of type DATE?
– Samuel Ribeiro
can yes. Time was just an example, the syntax is the same
– Danilo Cândido
Where exactly do I get the year? Since I’m working on Users
– Samuel Ribeiro
Edit your post and paste some code, so we know how you’re doing.
– Danilo Cândido
You can extract the year but it is not the correct one. You will spend storage saving the date there, the best solution is to change the field to whole.
– Alex Takitani
I understand Alex Takitani, but I don’t know how to make a select that shows the years and saves a whole
– Samuel Ribeiro