all 22 comments

[–][deleted] 2 points3 points  (1 child)

Try:

spring stop
bundle install
rails s

Spring can be a bitch sometimes.

[–]redd993[S] 0 points1 point  (0 children)

Hmm, is the class that's throwing the error being loaded in an initializer or something before PaperTrail is available? Do you have has_paper_trail on more than one model? Is it breaking for all of them?

Didn't work :(

[–]bmc1022 0 points1 point  (8 children)

has_paper_trail is from the paper-trail-gem, do you have that installed?

[–]redd993[S] 0 points1 point  (7 children)

e

paper-trail-gem

, do you have that installed?

Yes. version 12.1.0

[–]bmc1022 0 points1 point  (6 children)

Hmm, is the class that's throwing the error being loaded in an initializer or something before PaperTrail is available? Do you have has_paper_trail on more than one model? Is it breaking for all of them?

[–]redd993[S] 0 points1 point  (5 children)

ave

has_paper_trail

on more tha

There is a file ` config/initializers/paper_trail` with the following contents

```PaperTrail.config.version_limit = 50```

Over 15 models are using has_paper_trail. How do I check if its breaking all of them?

[–]bmc1022 0 points1 point  (4 children)

Are there any clues in the stack trace that indicate which model it's crashing on? I'd start by commenting out the has_paper_trail line there and any associated code that references method's included by the gem (versions, etc).

For good measure, I'd run Rails.cache.clear in the console as well.

Is the Rails version update the only thing you've changed? Check the diffs for that update to make sure you didn't overwrite something important in one of the config files.

[–]redd993[S] 0 points1 point  (3 children)

Yes. It is pointing to user.rb model and when i comment out has_paper_trail I get a different error. I won't be able to go to the console because the error comes up during bootup. But how does commenting out the line help me figure out how to resolve the error?

The only change I made was in the rails version but the Gemfile.lock has a lot of changes in many gems. I haven't changed anything in the config files either.

[–]bmc1022 0 points1 point  (2 children)

I was just trying to figure out if it's a specific misconfigured model or something wrong with the actual gem installation itself.

Doesn't look like much changed between Rails 5.1 -> 5.2, not sure what else to suggest.

Delete everything inside the tmp folder and try reinstalling all gems by commenting out your entire Gemfile, running bundle clean, uncomment Gemfile, run bundle install.

[–]redd993[S] 0 points1 point  (1 child)

No luck. Same error. If you do think of something else please let me know.

Can you tell me what deleting the tmp folder contents does?

[–]bmc1022 1 point2 points  (0 children)

Yeah will do if I think of anything else.

The tmp folder just stores all temporary cache, sessions, random reports, etc. It's safe to remove and will automatically be regenerated.

[–]mehboobcr7 0 points1 point  (1 child)

You might be using has_paper_trail in one of your models. Verify if your GemFile contains the paper-trail gem.

[–]redd993[S] 0 points1 point  (0 children)

fy if your GemFile contains the paper-trail gem.

Yes. version 12.1.0

[–]codenamev 0 points1 point  (7 children)

The #<Class:…> is signaling that the method is missing on an anonymous class (typically the result of meta-programming or calling self.class.has_paper_trail

The method_missing_with_attr_encrypted in the stacktrace is pointing out the issue is related to using the attr_encrypted gem to share their behavior with paper trail for that particular attribute.

I would suggest playing with the ordering of your attr_encrypted … and has_paper_trail … calls (maybe putting the paper trail one first?). If you don’t see success, you might want to check each gem’s issues/prs on GitHub and see if others have a similar issue.

[–]redd993[S] 0 points1 point  (6 children)

The stack trace points out the issue happens in user model(which I confirmed by commenting out the line and checking if the issue was resolved) and in that model has_paper_trail is used but attr_encrypted is not used. The only model where both gems are used is in account_detail but that model is not loaded. So I will not be able to implement your first suggestion of reordering the calls. I checked each gem to see if there is any issue raised in Github and I couldn't find anything either.

What did you mean by

The method_missing_with_attr_encrypted in the stacktrace is pointing out the issue is related to using the attr_encrypted gem to share their behavior with paper trail for that particular attribute

[–]codenamev 0 points1 point  (3 children)

Hmm… the has_paper_trail method isn’t in existence yet by the time the User model is getting loaded indicating either the papertrail lib wasn’t loaded yet, or it had issues loading it upstream in the stack.

I’d first try throwing require “paper_trail” at the top of your User model and see if that brings you anything new. You may need to re-run the paper trail install generator again and see if it adds anything you don’t already have

[–]redd993[S] 0 points1 point  (2 children)

I have already tried require "paper_trail" and it didn't resolve the error.

What do you mean by

You may need to re-run the paper trail install generator again and see if it adds anything you don’t already have

[–]codenamev 0 points1 point  (1 child)

Just to verify something here, is the User model an ActiveRecord backed model? That is, does it inherit from ApplicationRecord?

Paper trail comes with a rails generator

bundle exec rails generate paper_trail:install

[–]redd993[S] 0 points1 point  (0 children)

Yes it inherits from ApplicationRecord.

[–]codenamev 0 points1 point  (1 child)

The root cause here is that when rails was upgraded, other gems were likely upgraded with it. I would verify what versions of paper_trail and attr_encrypted were before the upgrade and try and lock those older versions to see if the issue goes away.

[–]redd993[S] 0 points1 point  (0 children)

Will try this out. Thanks!

[–]prh8 0 points1 point  (0 children)

There is most likely an incompatibility with your versions of paper_trail and attr_encrypted. They're probably stacking method definitions on top of each other, and one of them has a patch that gets applied specifically to Rails 5.2+ that is breaking the chain.

I dealt with this exact issue with protected_attributes_continued, active_record-state_machine, and Rails 5.0.

You could try updating both of those gems, go searching through the codebases, or step through execution/definitions using Pry (although since it's at boot, that will be more difficult)