Archiwum

Archive for the ‘Ruby’ Category

Rails: annotate gem – problem z generowaniem

12 września 2011 4 Komentarze

Tym razem krótko o RoR. Poznaję język i jednocześnie framework (3.1), przerabiając kolejne tutoriale.
Natrafiłem na problem przy tworzeniu modelu, a dokładnie przy generowaniu adnotacji do modelu.
Zainstalowałem potrzebny gem annotate

gem 'annotate', '2.4.0'

Przy próbie generowania adnotacji za pomocą komendy:

bundle exec annotate --position before

otrzymałem komunikat:

/usr/local/rvm/gems/ruby-1.9.3-preview1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:3:in `<top (require
d)>': undefined method `namespace' for main:Object (NoMethodError)
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/activerecord-3.1.0/lib/active_record/railtie.rb:26:in `load'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/activerecord-3.1.0/lib/active_record/railtie.rb:26:in `block in <cl
ass:Railtie>'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/railtie.rb:183:in `call'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/railtie.rb:183:in `block in load_tasks'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/railtie.rb:183:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/railtie.rb:183:in `load_tasks'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/engine.rb:395:in `block in load_tasks'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/application/railties.rb:8:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/application/railties.rb:8:in `all'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/engine.rb:395:in `load_tasks'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/application.rb:99:in `load_tasks'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `method_miss
ing'
        from Rakefile:7:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/gems/annotate-2.4.0/bin/annotate:66:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/bin/annotate:19:in `load'
        from /usr/local/rvm/gems/ruby-1.9.3-preview1/bin/annotate:19:in `<main>'

Problem jest brak ‚require rake’. Problem został rozwiązany ale chyba jeszcze nie ma wersji stabilnej z fixem.

Aby generowanie zaczęło działać wystarczy wcześniej wymienioną linijkę zamienić na:

gem 'annotate', '2.4.0', :git => 'git://github.com/jeremyolliver/annotate_models.git', :branch => 'rake_compatibility'

Oczywiście później w wierszu poleceń wywołujemy komendę

bundle install
Reklamy
Kategorie:Ruby, Ruby on Rails Tagi: