# ActiveRecord dynamic finder methods

**URL:** <https://www.ruby-forum.com/t/activerecord-dynamic-finder-methods/55214>\
**Category:** Ruby\
**Created:** [March 17, 2006, 11:43pm UTC](https://www.ruby-forum.com/t/activerecord-dynamic-finder-methods/55214 "2006-03-17T23:43:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![markcasio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@markcasio](https://www.ruby-forum.com/u/markcasio)\
**Post date:** [March 17, 2006, 11:43pm UTC](https://www.ruby-forum.com/t/activerecord-dynamic-finder-methods/55214/1 "2006-03-17T23:43:18Z")

</div>

I’ve received conflicting answers to this question and I’d like to  
confirm the correct answer.

When an ActiveRecord dynamic finder method is invoked, does it create  
a new method and save it so the method actually exists the next time  
it is called OR does it just evaluate the query based on the method  
name every time.

I don’t have an opinion on which way is better, I just want to know  
how it currently works.

---

<div class="post-metadata">

**Author:** ![markcasio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@markcasio](https://www.ruby-forum.com/u/markcasio)\
**Post date:** [March 18, 2006, 12:04am UTC](https://www.ruby-forum.com/t/activerecord-dynamic-finder-methods/55214/2 "2006-03-18T00:04:29Z")

</div>

On Mar 17, 2006, at 4:41 PM, Mark V. wrote:

> I’ve received conflicting answers to this question and I’d like to  
> confirm the correct answer.
> 
> When an ActiveRecord dynamic finder method is invoked, does it create  
> a new method and save it so the method actually exists the next time  
> it is called OR does it just evaluate the query based on the method  
> name every time.
> 
> I don’t have an opinion on which way is better, I just want to know  
> how it currently works.

You can always ask Ruby:

> > Member.respond\_to? :find\_by\_first\_name  
> > =\> false
> 
> > Member.find\_by\_first\_name(“James”)  
> > =\> #\<Member:0x2223208 …\>
> 
> > Member.respond\_to? :find\_by\_first\_name  
> > =\> false

James Edward G. II
