Railroad diagram generator does not work with "NoMethodError"

After making a few changes to the rails app I fiddled around, the railroad stopped working. The verbose output gives some hints. I wonder if other people have met this and if there is any advice on how to fix this problem. Is this a data modeling bug? Is this a railroad problem? The error log follows ...

railroad -vM Loading application environment
Loading application classes
Generating models diagram

...[snip]...

    Processing Person
        Processing model association authorships
        Processing model association person_image
        Processing model association publications
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/reflection.rb:224:in `derive_class_name': You have a nil object when you didn't expect it! (NoMethodError)
The error occurred while evaluating nil.class_name
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/reflection.rb:106:in `class_name'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:134:in `process_association'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:102:in `process_class'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:101:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:101:in `process_class'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:27:in `generate'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:26:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:26:in `generate'
    from /usr/lib/ruby/gems/1.8/gems/railroad-0.5.0/bin/railroad:47
    from /usr/bin/railroad:19:in `load'
    from /usr/bin/railroad:19

      

+1


source to share


2 answers


My point is that you have a stray "has_many" or "own_to" or other association call in your Person model ...

I am assuming your model looks something like



class Person
  has_many :authorships
  has_many :images
  has_many :publications
  has_many #with nothing after it
  # the rest
end

      

+1


source


You probably have has_many: through the association that is incorrect, something like

Person has_many: publications,: via => ...,: source => ...



make sure you have the source!

+1


source







All Articles