NoMethodError - undefined method `timestamp_sort_order' for Paper trail issue after upgrading Rails 4.2

南楼画角 提交于 2019-12-01 21:26:18

问题


I used paper_trail to tracking transnational changes when I migrated rails 3.2 to rails 4.2, have got below issue:

NoMethodError - undefined method `timestamp_sort_order' for


回答1:


I fixed this by adding below line in intializer paper_trail.rb file

PaperTrail::Rails::Engine.eager_load!

See my final intializers/paper_trail.rb file

PaperTrail::Rails::Engine.eager_load!

module PaperTrail

  class Version < ActiveRecord::Base
    .....
  end

end

Problem resolved....




回答2:


got this on rails 6.0.0beta3 because I patched papertrail and forgot to add PaperTrail::VersionConcern, e.g.:

module PaperTrail
  class Version < ::ActiveRecord::Base
    include PaperTrail::VersionConcern
  end
end

PaperTrail::Rails::Engine.eager_load! did not fix it for me

looking at the source code it's calling it directly on an ActiveRecord::Base model, it's defined on PaperTrail::VersionConcern.



来源:https://stackoverflow.com/questions/31716983/nomethoderror-undefined-method-timestamp-sort-order-for-paper-trail-issue-af

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!