paper_trail: Custom initializer breaks PaperTrail 3.0.3 (rails 3.2)
3.0.3 seems to be breaking when calling has_paper_trail in a model. 3.0.2 works fine. top of the stack:
undefined method `timestamp_sort_order' for #<Class:0x007fd1d02fad60>
activerecord (3.2.18) lib/active_record/dynamic_matchers.rb:55:in `method_missing'
paper_trail (3.0.3) lib/paper_trail/has_paper_trail.rb:70:in `has_paper_trail'
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (1 by maintainers)
Commits related to this issue
- fixed see https://github.com/airblade/paper_trail/issues/392 — committed to flockom/paper_trail_test by flockom 10 years ago
- close #392; Update README instructions to include instructions for how to use a custom initializer and prevent breakage of the Rails::Engine functionality [ci skip] — committed to paper-trail-gem/paper_trail by batter 10 years ago
- Correção do problema com o PaperTrail 3.0.3 O PaperTrail 3.0.3 foi removido do RubyGems, por conter alguma falha e o mesmo foi substituído pela versão 3.0.5. No entanto na versão 3.0.5 um workaround... — committed to UFSC/moodle-tcc by brodock 10 years ago
So one workaround that you can use for now is placing this line in your custom initializer, like so:
But, it seems as though then the model doesn’t end up getting loaded in through the
Rails::Engine, which defeats the whole purpose of the feature, so I need to do more research to figure out what we can do to work around that.Another workaround is to manually require the version class from your initializer. Again, I believe this circumvents the benefits that come from loading the model in through a
Rails::Engineto begin with, but it is another way to do it:After doing a little more experimentation, it appears as though this may be the correct way to make it work properly. You want to change your initializer so that the model has already been eager loaded by the engine by the time this code gets executed, by calling
eager_load!on the engine, like so:Looks like I will need to update the README accordingly. Glad I was able to find the proper method for getting this to work. I’ll keep this open until I can update the README appropriately.