# Problem with scope

**URL:** <https://discuss.rubyonrails.org/t/problem-with-scope/62890>\
**Category:** rubyonrails-talk\
**Created:** [February 19, 2012, 12:39am UTC](https://discuss.rubyonrails.org/t/problem-with-scope/62890 "2012-02-19T00:39:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![byron\_appelt](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@byron\_appelt](https://discuss.rubyonrails.org/u/byron_appelt)\
**Post date:** [February 19, 2012, 12:39am UTC](https://discuss.rubyonrails.org/t/problem-with-scope/62890/1 "2012-02-19T00:39:15Z")

</div>

I have two related models such as this:

class PartCategory \< ActiveRecord::Base &nbsp;&nbsp;has\_many :part\_types &nbsp;&nbsp;scope :engine, where(:name =\> 'Engine') end

class PartType \< ActiveRecord::Base &nbsp;&nbsp;belongs\_to :part\_category end

I would like to add a scope to the PartType model such as:

&nbsp;&nbsp;&nbsp;scope :engine\_parts, lambda { joins(:part\_category).engine }

But when I try that, I get the following error:

NoMethodError: undefined method `default_scoped?' for ActiveRecord::Base:Class &nbsp;&nbsp;from /Users/bappelt/RubymineProjects/MyStreetMachine/idunno42!/ruby/ 1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:1082:in `method\_missing' &nbsp;&nbsp;from /Users/bappelt/RubymineProjects/MyStreetMachine/idunno42!/ruby/ 1.9.1/gems/activerecord-3.1.0/lib/active\_record/relation/ spawn\_methods.rb:11:in `merge' &nbsp;&nbsp;from /Users/bappelt/RubymineProjects/MyStreetMachine/idunno42!/ruby/ 1.9.1/gems/activerecord-3.1.0/lib/active_record/named_scope.rb:182:in `block in scope' &nbsp;&nbsp;from (irb):1 &nbsp;&nbsp;from /Users/bappelt/RubymineProjects/MyStreetMachine/idunno42!/ruby/ 1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start' &nbsp;&nbsp;from /Users/bappelt/RubymineProjects/MyStreetMachine/idunno42!/ruby/ 1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start' &nbsp;&nbsp;from /Users/bappelt/RubymineProjects/MyStreetMachine/idunno42!/ruby/ 1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:40:in `\<top (required)\>' &nbsp;&nbsp;from script/rails:6:in `require' &nbsp;&nbsp;from script/rails:6:in `\<main\>'

I don't have a lot of experience with the scope thing, so I am probably missing something fundamental here. Can someone please tell me what it is.
