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

Bug with --only and -only_recursion_depth #376

Open
LucasCarrias opened this issue Mar 8, 2022 · 0 comments
Open

Bug with --only and -only_recursion_depth #376

LucasCarrias opened this issue Mar 8, 2022 · 0 comments

Comments

@LucasCarrias
Copy link

What:

An exception is raised when you provide a single model name with --only and --only_recursion_depth

Step to reproduce:

At the CLI, enter --only with just one model name, then provide --only_recursion_depth with any valid integer.

Example:
erd --only ModelName --only_recursion_depth=1

Debug:

rails-erd 1.6.1

Failed: NoMethodError: undefined method `each' for "ModelName":String
    from /home/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rails-erd-1.6.1/lib/rails_erd/diagram.rb:129:in `generate'
    from /home/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rails-erd-1.6.1/lib/rails_erd/diagram.rb:119:in `create'
    from /home/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rails-erd-1.6.1/lib/rails_erd/diagram.rb:74:in `create'
    from /home/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rails-erd-1.6.1/lib/rails_erd/cli.rb:193:in `create_diagram'
    from /home/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rails-erd-1.6.1/lib/rails_erd/cli.rb:167:in `start'
    from /home/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rails-erd-1.6.1/lib/rails_erd/cli.rb:156:in `start'
    from /home/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/rails-erd-1.6.1/bin/erd:4

Possible fix:

Make sure that options[:only] is always an array

options[:only].dup.each do |class_name|
options[:only]+= recurse_into_relationships(@domain.entity_by_name(class_name), depth)
end
options[:only].uniq!

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