views:

364

answers:

1

Hi everone,

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.

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!

A: 

Your version of Ruby, probably 1.8.7 or even more recent, is too modern for attachment_fu. To fix this, you need to change attachment_fu itself. Edit the file vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb and on line 66 change:

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. Attachment_fu is not supported any longer. Paperclip is used these days.

This error is described in more detail here.

Joost Baaij