views:

575

answers:

2

After making a few modifications to a rails app I am tinkering on, railroad stopped working. The verbose output gives some clues. I wonder if other folks have encountered this and if there are some pointers for fixing this problem. Is it a data modeling error? Is it a problem with railroad? 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  A: 

I want to say you have an stray "has_many" or "belongs_to" or other association call in your Person model...

I am guess 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
diclophis
+1  A: 

You probably have a has_many :through association that is incorrectly specified, something like

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

make sure you have the source in there!