Friday, July 29, 2011

Getting error "`method_missing': undefined method `named_scope' for # (NoMethodError)"

In my application, I am using Clicksteam plugin. While upgrading to Rails 3.1.0.rc5, getting following error:

 /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activerecord-3.1.0.rc5/lib/active_record/base.rb:1095:in `method_missing': undefined method `named_scope' for #<Class:0x3668480> (NoMethodError)
    from /Users/ror/projects/restaurant/vendor/plugins/clickstream/lib/app/models/stream.rb:8
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/vendor/plugins/clickstream/lib/clickstream.rb:3
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/vendor/plugins/clickstream/rails/init.rb:1
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/vendor/plugins/clickstream/init.rb:2
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/plugin.rb:80
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:25:in `instance_exec'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:25:in `run'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:50:in `run_initializers'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:49:in `each'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/initializable.rb:49:in `run_initializers'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/application.rb:92:in `initialize!'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/railtie/configurable.rb:30:in `send'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/railties-3.1.0.rc5/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/ror/projects/restaurant/config/environment.rb:6
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/activesupport-3.1.0.rc5/lib/active_support/dependencies.rb:237:in `require'
    from /Users/ror/projects/restaurant/config.ru:4
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/rack-1.3.2/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/ror/projects/restaurant/highline/ruby/1.8/gems/rack-1.3.2/lib/rack/builder.rb:51:in `initialize'
    from /Users/ror/projects/restaurant/config.ru:1:in `new'
    from /Users/ror/projects/restaurant/config.ru:1 

 Solution to fix the problem:
Change 'named_scope' to 'scope' in line no - 8 in
vendor/plugins/clickstream/lib/app/models/steam.rb

3 comments:

  1. I've been beating my head on this for half an hour. Hardly anyone seems to be using ActiveRecord without Rails. Thanks for the tip, resolved my issue.

    ReplyDelete
  2. Nice one! I had this same issue using ActiveRecord 3.2.8 with Padrino and changing 'named_scope' to just 'scope' in my model fixed things for me.

    ReplyDelete