Open zedtux opened 6 years ago
What's your model code? How did you declare your attributes?
Sorry to not have provided my code 😞. Here it is:
class Request
include NoBrainer::Document
before_create :populates_created_at
field :url, type: String
field :created_at, type: Time, index: true
private
def populates_created_at
self.created_at = Time.zone.now
end
end
Thank you. Internally, NoBrainer uses Time#getlocal.
Example:
~/brainy (development) > Time.now.utc
=> 2018-01-11 13:29:35 UTC
~/brainy (development) > Time.now.utc.getlocal
=> 2018-01-11 08:29:37 -0500
What do you get?
The settings of the Rails time_zone is not taken in account. Maybe we can have another setting that uses the Rails configuration instead? The place to add this code is here: https://github.com/nviennot/nobrainer/blob/master/lib/no_brainer/document/types/time.rb#L35 Feel free to make a pull request :) :)
Thank you @nviennot for your comment 👍.
Right now, I'm working on having AASM compatible with NoBrainer, but the I can try to implement this too. Thank you for having pointed me to the right place :)
I'm done with AASM, if you want to have a look and give feedbacks: https://github.com/aasm/aasm/pull/522.
I will now check for this timestamp issue.
Great work!
I put a few comments in the pull request
Thank you @nviennot. Where are your comments? I can't see them.
Forgot to press "submit review". Should be in
Time
records attributes of my application are saved in UTC in RethinkDB, which is fine by me, but now I'd like to show them in the current timezone.I have updated my Rails app
config/application.rb
file in order to set thetime_zone
:And I have updated the NoBrainer initializer:
Restarted everything but my dates and times are still displayed in UTC:
(This should be with an hour more 11:31:56)
Can you please tell me what am I doing wrong?