I\'m working on a project with a rails api and an iOS client, using the updated_at field as the reference to detect modifications on the server that happened after the last
If you're using the ISO8601 standard you can use .iso8601(10)
. Don't know why but it rounds to seconds by default.
Try
Model.where("updated_at > ?", last_update.strftime("%Y-%m-%dT%H:%M:%S.%N%z"))
You can also set this format as the standard format for DateTime in databases by setting (i.e. in an initiallizer):
Time::DATE_FORMATS[:db]= '%Y-%m-%dT%H:%M:%S.%N%z'
then your original query works again:
Model.where("updated_at > ?", last_update)
See the Rails API for DateTime.to_s
(aka .to_formated_s)