# Got NoMethodError on Model's find method

**URL:** <https://www.ruby-forum.com/t/got-nomethoderror-on-models-find-method/178848>\
**Category:** Rails\
**Created:** [November 12, 2009, 7:24am UTC](https://www.ruby-forum.com/t/got-nomethoderror-on-models-find-method/178848 "2009-11-12T07:24:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adinda\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@adinda\_p](https://www.ruby-forum.com/u/adinda_p)\
**Post date:** [November 12, 2009, 7:24am UTC](https://www.ruby-forum.com/t/got-nomethoderror-on-models-find-method/178848/1 "2009-11-12T07:24:31Z")

</div>

Hi All,

I don’t know how this could happen. I got NoMethodError on running a  
simple  
Model’s find method. At first i have the same error for running  
find\_all\_by\_country method where country is one of the model’s  
attributes.  
So, running a find method also doesn’t help. I have no problem running  
the  
methods on rails console. What should i check? Has anyone had a problem  
like  
this before?

My app running on a frozen rails 2.3.4 on OSX 10.6.2, ruby 1.8.7  
patchlevel  
174.

Thanks,  
Adinda P

---

<div class="post-metadata">

**Author:** ![adinda\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@adinda\_p](https://www.ruby-forum.com/u/adinda_p)\
**Post date:** [November 12, 2009, 7:43am UTC](https://www.ruby-forum.com/t/got-nomethoderror-on-models-find-method/178848/2 "2009-11-12T07:43:50Z")

</div>

I chat with someone. He told me to put this line before calling find  
method  
just to check in the development log:

logger.info self.class.methods.sort; return true

As far as I know it has nothing to do with the problem, but it works. Is  
there a setting that i don’t get correctly?

Thanks,  
Adinda

---

<div class="post-metadata">

**Author:** ![adinda\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@adinda\_p](https://www.ruby-forum.com/u/adinda_p)\
**Post date:** [November 13, 2009, 4:51am UTC](https://www.ruby-forum.com/t/got-nomethoderror-on-models-find-method/178848/3 "2009-11-13T04:51:48Z")

</div>

Hi all,

Here’s the pastie [http://pastie.org/694864](http://pastie.org/694864) that describe my situation.  
If  
you see the console section, flc is a Clan record. I can ran  
‘find\_all\_by\_country’ method. However, when i ran the  
‘users\_within\_country’  
method, i got NoMethodError on line 2.

Here are some updates. I was suggested to use searchlogic gem and i got  
similar error

NoMethodError: undefined method `country_equals` for Clan

I tried this on other ruby versions like: 1.8.7p72 (comes from Snow  
Leopard  
DVD), 1.8.6p114 on OpenSuSE and i still have the same error. I’m using  
frozen Rails 2.3.4. I don’t know what to do now? What should i check?  
Any  
suggestion?

Thanks,  
Dida

---

<div class="post-metadata">

**Author:** ![adinda\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@adinda\_p](https://www.ruby-forum.com/u/adinda_p)\
**Post date:** [November 13, 2009, 10:42am UTC](https://www.ruby-forum.com/t/got-nomethoderror-on-models-find-method/178848/4 "2009-11-13T10:42:26Z")

</div>

On Nov 13, 3:50 am, Adinda P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi all,
> 
> Here’s the pastiehttp://pastie.org/694864that describe my situation. If  
> you see the console section, flc is a Clan record. I can ran  
> ‘find\_all\_by\_country’ method. However, when i ran the ‘users\_within\_country’  
> method, i got NoMethodError on line 2.

Looking at your snippet, it looks like users\_within\_country is a class  
method - if so you can’t call it on instances.

Fred
