A
A
Andrey Fedorov2015-04-18 21:00:03
Ruby on Rails
Andrey Fedorov, 2015-04-18 21:00:03

How to update Activerecord with unixtimestamp time?

I suspect that the solution is simple, but I did not find something in the dock.
With the help of ajax, I send a parameter update, where one of the attributes is unixtimestamp.
But in Order and in the database it is datetime.
Now I do this:

order = params[:order]
order[:order_date] = Time.at(order[:order_date].to_i).to_datetime
order_item.update_attributes(order.permit( :order_date))

But I suspect this is a very crooked decision and everything has already been done before me.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question