简体   繁体   English

Ruby Railroad图生成器失败,并在Enumerable :: Enumerator中出现[]的NoMethodError

[英]Ruby Railroad diagram generator fails with NoMethodError for [] in Enumerable::Enumerator

I'm trying to generate model diagrams using the railroad gem. 我正在尝试使用铁路宝石生成模型图。 I have managed to generate a diagram for a different app, but I'm trying to get my head around some "legacy" code, and keep running into problems. 我设法为另一个应用程序生成了一个图表,但是我试图绕过一些“旧版”代码,并不断遇到问题。

I know very little about ruby or rails, so any help would be appreciated... 我对红宝石或铁轨知之甚少,所以任何帮助将不胜感激...

Basically, I run: 基本上,我运行:

$ railroad -v -M

and get: 并得到:

Loading application environment
Loading application classes
./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/string/access.rb:43:in `first': undefined method `[]' for #<Enumerable::Enumerator:0xb70a72d0> (NoMethodError)
from ./config/../vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:70:in `has_attachment'
from ./app/models/asset.rb:5
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
from ./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'
from ./config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:495:in `require'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:40:in `load_classes'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:40:in `each'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:40:in `load_classes'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/app_diagram.rb:21:in `initialize'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/lib/railroad/models_diagram.rb:14:in `initialize'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/bin/railroad:36:in `new'
from /home/myname/.gem/ruby/1.8/gems/railroad-0.5.0/bin/railroad:36
from /home/myname/.gem/ruby/1.8/bin/railroad:19:in `load'
from /home/myname/.gem/ruby/1.8/bin/railroad:19

I've tried reinstalling attachment_fu (it was already in the vendor/plugins folder) but that didn't seem to help. 我试过重新安装attachment_fu(它已经在vendor / plugins文件夹中),但这似乎无济于事。

I wouldn't be surprised if there was a problem with the schema - I've already had to fix typos in column names, missing references, that kind of thing. 如果架构存在问题,我也不会感到惊讶-我已经不得不修复列名中的拼写错误,缺少引用之类的问题。 Is there anyway I can work out where it might be dying? 无论如何,我可以算出可能快要死了的地方吗?

Thanks a lot! 非常感谢!

Your version of Ruby, probably 1.8.7 or even more recent, is too modern for attachment_fu. 您的Ruby版本(可能是1.8.7或更高版本)对于attachment_fu而言太现代了。 To fix this, you need to change attachment_fu itself. 要解决此问题,您需要更改attachment_fu本身。 Edit the file vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb and on line 66 change: 编辑文件vendor / plugins / attachment_fu / lib / technoweenie / attachment_fu.rb,然后在第66行进行更改:

options[:path_prefix].first == '/'

(at the end) to (最后)到

options[:path_prefix].starts_with? == '/'

Alternatives are to downgrade your version of Ruby to 1.8.6 (probably, perhaps even lower) or use a different plugin. 替代方法是将Ruby版本降级至1.8.6(可能更低,甚至更低)或使用其他插件。 Attachment_fu is not supported any longer. 不再支持Attachment_fu。 Paperclip is used these days. 这些天使用回形针

This error is described in more detail here . 此错误将在此处更详细地描述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM