在对rails应用程序进行一些修改后,我正在修补,铁路停止工作。详细输出提供了一些线索。我想知道其他人是否遇到过此问题以及是否有一些指针可以解决这个问题。这是数据建模错误吗?这是铁路的问题吗?错误日志如下......
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
答案 0 :(得分:1)
我想说你的个人模型中有一个迷路的“has_many”或“belongs_to”或其他关联调用......
我猜您的模型看起来像
class Person
has_many :authorships
has_many :images
has_many :publications
has_many #with nothing after it
# the rest
end
答案 1 :(得分:1)
你可能有一个has_many:通过错误指定的关联,比如
Person has_many:publications,:through => ......,:source => ...
确保你有源!