# Method\_exists? is missing?

**URL:** <https://www.ruby-forum.com/t/method-exists-is-missing/165167>\
**Category:** Rails\
**Created:** [April 9, 2009, 7:16pm UTC](https://www.ruby-forum.com/t/method-exists-is-missing/165167 "2009-04-09T19:16:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 9, 2009, 7:16pm UTC](https://www.ruby-forum.com/t/method-exists-is-missing/165167/1 "2009-04-09T19:16:37Z")

</div>

In a controller run through webrick I do this:

@entity = Entity.new  
print @entity.methods.sort.to\_yaml

and I see this:

- logger
- mark\_for\_destruction
- marked\_for\_destruction?
- metaclass
- method
- method\_missing
- methods
- new\_record?

There is no method\_exists? method. If I instead do this in a console  
session, I see this:

$ script/console

> > @entity = Entity.new  
> > =\> …
> 
> > print @entity.methods.sort.to\_yaml  
> > …

- logger
- mark\_for\_destruction
- marked\_for\_destruction?
- metaclass
- method
- method\_exists?
- method\_missing
- methods
- mocha
- mocha\_inspect
- new\_record?  
…

However, if I remove the mocha gem (0.9.5) then method\_exists?  
disappears from Entities created in the console as well.

So, what gives?

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 9, 2009, 8:42pm UTC](https://www.ruby-forum.com/t/method-exists-is-missing/165167/2 "2009-04-09T20:42:49Z")

</div>

James B. wrote:

> So, what gives?

Turns out I should be using #respond-\_to? instead. Method\_missing? is  
part of mocha.
