'Error on reify a version using ruby PaperTrail
I followed the instructions in https://github.com/paper-trail-gem/paper_trail
Added the paper_trail gem in the project Gemfile:
gem 'paper_trail'
Executed the following commands:
bundle exec rails generate paper_trail:install
bundle exec rake db:migrate
I have added the has_paper_trail
to the model.
When I make a change on an instance of that model, I can see that a record is added to the versions table and I can access these records using model.versions
.
I am trying now to reify one of the versions, but I am getting the following error:
/core/ruby/cache/ruby/2.7.0/gems/pry-0.12.2/lib/pry/exceptions.rb:28: warning: $SAFE will become a normal global variable in Ruby 3.0
TypeError: uninitialized Time
from /core/ruby/cache/ruby/2.7.0/gems/activemodel 6.1.4.7/lib/active_model/type/helpers/time_value.rb:29:in `nsec'
What I can see is that it fails in the following method when it's trying to evaluate value.nsec
def apply_seconds_precision(value)
return value unless precision && value.respond_to?(:nsec)
number_of_insignificant_digits = 9 - precision
round_power = 10**number_of_insignificant_digits
rounded_off_nsec = value.nsec % round_power
if rounded_off_nsec > 0
value.change(nsec: value.nsec - rounded_off_nsec)
else
value
end
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|