Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `name' for nil:NilClass (seems to be related to PaperTrail) #411

Open
krisleech opened this issue Sep 8, 2023 · 0 comments

Comments

@krisleech
Copy link

krisleech commented Sep 8, 2023

There seems to have been a fix back in 2019 but it was not merged and the author has since deleted their fork.

Given it seems to be related to PaperTrail I excluded all classes descendent from PaperTrail::Version in .erdconfig but this did not help. I found the list of Version models as such:

Zeitwerk::Loader.eager_load_all
PaperTrail::Version.descendants.map(&:name).sort.join(',')

I did some digging and it seems to be related to a relationship.destination being nil:

From: /Users/kris/.gem/ruby/3.2.2/gems/rails-erd-1.7.2/lib/rails_erd/domain.rb:111 RailsERD::Domain#relationships_mapping:

    104:     def relationships_mapping
    105:       @relationships_mapping ||= {}.tap do |mapping|
    106:         relationships.each do |relationship|
    107:           (mapping[relationship.source.name] ||= []) << relationship
    108:           (mapping[relationship.destination.name] ||= []) << relationship
    109: rescue StandardError => e
    110: binding.pry
 => 111:         end
    112:       end
    113:     end

[9] pry(#<RailsERD::Domain>)> e
=> #<NoMethodError: undefined method `name' for nil:NilClass>

[10] pry(#<RailsERD::Domain>)> relationship
=> #<RailsERD::Domain::Relationship:0x000000000b1da0 @source=Item @destination=>

[11] pry(#<RailsERD::Domain>)> relationship.destination
=> nil

[12] pry(#<RailsERD::Domain>)> relationship.destination.name
NoMethodError: undefined method `name' for nil:NilClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant