# Are find\_by and find\_or\_create\_by depreacated?

**URL:** <https://www.ruby-forum.com/t/are-find-by-and-find-or-create-by-depreacated/116338>\
**Category:** Rails\
**Created:** [October 4, 2007, 4:27pm UTC](https://www.ruby-forum.com/t/are-find-by-and-find-or-create-by-depreacated/116338 "2007-10-04T16:27:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbrubacher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ee59a6/32.png) [@fbrubacher](https://www.ruby-forum.com/u/fbrubacher)\
**Post date:** [October 4, 2007, 4:27pm UTC](https://www.ruby-forum.com/t/are-find-by-and-find-or-create-by-depreacated/116338/1 "2007-10-04T16:27:45Z")

</div>

Hey all !

I tried using both this methods on rails edge and got method missing ,  
looked for them in a model.methds in “script/console” but no luck …  
Anyone can help !?

Regards

---

<div class="post-metadata">

**Author:** ![fbrubacher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ee59a6/32.png) [@fbrubacher](https://www.ruby-forum.com/u/fbrubacher)\
**Post date:** [October 4, 2007, 4:47pm UTC](https://www.ruby-forum.com/t/are-find-by-and-find-or-create-by-depreacated/116338/2 "2007-10-04T16:47:05Z")

</div>

Hi,

> I tried using both this methods on rails edge and got method missing ,  
> looked for them in a model.methds in “script/console” but no luck …

you will not see those methods by using .methods on a new object since  
the methods are dynamically created. Notice you can have a _huge_ number  
of combinations if you have a table with some fields, and Active Record  
is not going to create every single of the possible methods for you  
unless you are going to use them.

Suppose you are trying to execute  
Model.find\_all\_by\_size\_and\_color\_and\_model\_and\_material. Since that  
method is undefined, method\_missing will be invoked for your class, and  
ActiveRecord will make “the magic” at that moment. It will check if the  
signature of the method makes sense with the attributes for that  
particular model, and if it does, it will execute the find for you.  
Moreover, since ruby is dynamic, AR will define a method with that  
signature on the fly for this class, so next time you call it you will  
save all the process of hitting method\_missing and so on.

This means you will not be able to see the method by invoking .methods  
until you execute a find and it gets dynamically defined.

regards,

javier ramirez

---

<div class="post-metadata">

**Author:** ![fbrubacher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ee59a6/32.png) [@fbrubacher](https://www.ruby-forum.com/u/fbrubacher)\
**Post date:** [October 4, 2007, 5:05pm UTC](https://www.ruby-forum.com/t/are-find-by-and-find-or-create-by-depreacated/116338/3 "2007-10-04T17:05:20Z")

</div>

Uh got it … more method\_missisng Ruby Magic ! 🙂 Silly stupid  
me ! 🙂

Thanks !
