annotate_models icon indicating copy to clipboard operation
annotate_models copied to clipboard

Does it work with rails 3.1rc?

Open swachian opened this issue 15 years ago • 29 comments

For the first time I use this gem. I find it work on a project with rails3.0, yet I fail to make it run with rails3.1. The rails version I use include 3.1.0.rc4 and 3.1.0.rc3.

The error I get is like:

ree-1.8.7-2011.03@r310/gems/activerecord-3.1.0.rc4/lib/active_record/railties/databases.rake:3: undefined method `namespace' for main:Object (NoMethodError)
.....

        from ./Rakefile:7
        from /.rvm/gems/ree-1.8.7-2011.03@r310/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'

swachian avatar Jun 10 '11 15:06 swachian

Same problem here with Ruby 1.9.2 and Rails 3.1.0.rc4

/Users/manuel/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc4/lib/active_record/railties/databases.rake:3:in `<top (required)>': undefined method `namespace' for main:Object (NoMethodError)
    from /Users/manuel/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:in `load'
    from /Users/manuel/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:in `block in load'
    from /Users/manuel/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `block in load_dependency'
    from /Users/manuel/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/manuel/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/manuel/.rvm/gems/[email protected]/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:233:in `load'
    from /Users/manuel/.rvm/gems/[email protected]/gems/activerecord-3.1.0.rc4/lib/active_record/railtie.rb:26:in `block in <class:Railtie>'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:in `call'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:in `block in load_tasks'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:in `each'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/railtie.rb:182:in `load_tasks'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/application.rb:103:in `block in load_tasks'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/application/railties.rb:8:in `each'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/application/railties.rb:8:in `all'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/application.rb:103:in `load_tasks'
    from /Users/manuel/.rvm/gems/[email protected]/gems/railties-3.1.0.rc4/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from Rakefile:7:in `<top (required)>'
    from /Users/manuel/.rvm/gems/[email protected]/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'
    from /Users/manuel/.rvm/gems/[email protected]/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks'
    from /Users/manuel/.rvm/gems/[email protected]/gems/annotate-2.4.0/bin/annotate:66:in `<top (required)>'
    from /Users/manuel/.rvm/gems/[email protected]/bin/annotate:19:in `load'
    from /Users/manuel/.rvm/gems/[email protected]/bin/annotate:19:in `<main>'

manuelmeurer avatar Jun 14 '11 21:06 manuelmeurer

Anyone care to patch?

ctran avatar Jun 15 '11 20:06 ctran

Sure, if you give me a pointer to what the problem might be. :) It's deep in Rails so it might be a Rails issue? Or must some dependency be loaded first in annotate-2.4.0/lib/annotate.rb?

manuelmeurer avatar Jun 15 '11 20:06 manuelmeurer

Just encountered the same issue. I suspect it's more to do with rake 0.9, than rails 3.1 The rake task loading changed from 0.8.7 to 0.9.X Some rake methods were namespaced into Rake::DSL so include Rake::DSL if defined?(Rake::DSL) might help, though I haven't tried this yet.

I might have a play with patching/fixing this later

jeremyolliver avatar Jun 20 '11 05:06 jeremyolliver

Didn't work for me. I tried inserting include Rake::DSL in different places to no avail...

manuelmeurer avatar Jun 20 '11 06:06 manuelmeurer

Started on trying out a patch just now, but missing a few dev tools as I'm on a new computer, I'll continue this later.

For anyone else trying to write a patch, it took a bit for me to work out what the development dependencies for annotate are, so I added them to the gemspec, and corrected a couple of load calls here. I'll send a pull-request for those changes once I've had a bit more of a play around and hopefully figured out this issue

jeremyolliver avatar Jun 20 '11 10:06 jeremyolliver

Managed to work out what looks like a quite small fix to get this working over at: https://github.com/ctran/annotate_models/pull/29 (would have attached the pull request here if I knew how, not sure if that's possible)

jeremyolliver avatar Jun 21 '11 00:06 jeremyolliver

+1 Great!

manuelmeurer avatar Jun 21 '11 09:06 manuelmeurer

Can you tell me how to install the new update?

swachian avatar Jun 21 '11 09:06 swachian

@swachian, The easiest way is to wait for @ctran to pull in that change into the main repository and release a new version. If you don't want to wait, add the following to your Gemfile:

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

manuelmeurer avatar Jun 21 '11 09:06 manuelmeurer

I'm doing exactly what manuel says, specifying via a git branch, though I'm using 'dependency_compatibility' as the branch, which includes both pull requests I submitted #29 and #30 and once these are released into a new version, I'll be switching back to a standard install.

jeremyolliver avatar Jun 21 '11 09:06 jeremyolliver

@ctran Thanks for getting these merged in :) Looks like this issue, and issue #12 can be closed off now.

jeremyolliver avatar Jun 22 '11 00:06 jeremyolliver

Thanks to all

swachian avatar Jun 22 '11 01:06 swachian

i updated my annotate using gem 'annotate', :git => "https://github.com/ctran/annotate_models.git" and it still happens to me. is there any other fix or branch i should get?

corroded avatar Jun 26 '11 10:06 corroded

@corroded are you remembering to call the correct executable via bunde exec annotate ? Otherwise the existing install of annotate will be used, not the most up to date one you've installed via git

jeremyolliver avatar Jun 26 '11 11:06 jeremyolliver

oh oh oh. sorry i forgot about that! I should've just uninstalled and installed the gem instead of just doing another bundle install(which probably didn't refresh the installation) thanks for the reminder!

corroded avatar Jun 26 '11 16:06 corroded

I had this same error. Got it to work by simply adding require 'rake' in my Rakefile.

EDIT: Oh, I guess this was the small fix jeremyolliver was referring to, except it patches annotated.rb specifically.

calvinl avatar Jul 22 '11 18:07 calvinl

Easy one

m00nh3ck avatar Jul 25 '11 21:07 m00nh3ck

Thanks Jeremy for the fix. I'm currently working my way through Michael Hartl's RonR3 tutorial and this was a big help.

spindola avatar Oct 02 '11 18:10 spindola

As calvinl commented ,it just need a require 'rake' in file Rakefile. Thanks a lot.

eeewxj avatar Oct 05 '11 06:10 eeewxj