# Model method missing

**URL:** <https://discuss.rubyonrails.org/t/model-method-missing/10461>\
**Category:** rubyonrails-talk\
**Created:** [March 19, 2007, 8:51am UTC](https://discuss.rubyonrails.org/t/model-method-missing/10461 "2007-03-19T08:51:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Wang](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Michael\_Wang](https://discuss.rubyonrails.org/u/Michael_Wang)\
**Post date:** [March 19, 2007, 8:51am UTC](https://discuss.rubyonrails.org/t/model-method-missing/10461/1 "2007-03-19T08:51:21Z")

</div>

Filip Koczorowski wrote:

> I extended one of my model classes with a method, like this:
> 
> class Poll \< ActiveRecord::Base
> 
> &nbsp;&nbsp;has\_many :poll\_answers
> 
> &nbsp;&nbsp;def find\_active\_for &nbsp;&nbsp;&nbsp;&nbsp;# [...] method body &nbsp;&nbsp;end
> 
> end
> 
> However, when I tried this in the controller class:
> 
> def show &nbsp;&nbsp;@classroom = Classroom.find params[:id] &nbsp;&nbsp;@lesson\_groups = LessonGroup.find :all, :conditions =\> ['classroom\_id=?', @classroom.id], :include =\> :lessons
> 
> &nbsp;&nbsp;@poll = Poll.find\_active\_for # my model method end
> 
> ...I got a method\_missing:
> 
> NoMethodError (undefined method `find_active_for' for Poll:Class): &nbsp;&nbsp;&nbsp;&nbsp;/vendor/rails/activerecord/lib/active_record/base.rb:1129:in `method\_missing' &nbsp;&nbsp;&nbsp;&nbsp;/app/controllers/classroom\_controller.rb:9:in `show'
> 
> How is that possible? The class (Poll) gets loaded - I've inserted debug "logger.info" in poll.rb before and after class definition and they show up in the logs.
> 
> And by the way, I tried accessing this method in a unit test as well, with the same results.

Put a "self." at the front of the method name:

def self.find\_active\_for &nbsp;&nbsp;&nbsp;# [...] method body end
