# Validate callback balks when using AR.find method

**URL:** <https://www.ruby-forum.com/t/validate-callback-balks-when-using-ar-find-method/162111>\
**Category:** Rails\
**Created:** [March 5, 2009, 9:27pm UTC](https://www.ruby-forum.com/t/validate-callback-balks-when-using-ar-find-method/162111 "2009-03-05T21:27:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [March 5, 2009, 9:27pm UTC](https://www.ruby-forum.com/t/validate-callback-balks-when-using-ar-find-method/162111/1 "2009-03-05T21:27:01Z")

</div>

In an AR model (PrivilegedUser), I have several custom validations, so  
am using validate method to call a sequence of other small methods which  
perform specific tasks.

def validate  
do\_this  
do\_that  
end

In do\_this, I need to look up records from the same table/model I am in  
to do some comparing of the current object being created/updated to  
existing data.

def do\_this  
results = PrivilegedUser.find(:all, :condition =\> … )  
…do some stuff…  
end

No matter what form I try that find method with (find, self.find,  
PrivilegedUser.find), Rails balks that find is not a method of  
PrivilegedUser.

If I substitute PrivilegedUser.find with some other class, it works just  
fine. PrivilegedUser is a working AR subclass that I have been using for  
months, and am now adding this new method, and I already have find being  
used in other methods. So, there’s something unique about trying to use  
find in the validation callback somehow.

I’m obviously not understanding something. Can someone essplain to me?  
Thx.

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [March 5, 2009, 9:41pm UTC](https://www.ruby-forum.com/t/validate-callback-balks-when-using-ar-find-method/162111/2 "2009-03-05T21:41:21Z")

</div>

I do exactly what you describe with no problems. Are you sure you have  
not  
just got a typo somewhere that your brain is refusing to see?

2009/3/5 Greg W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [March 5, 2009, 9:51pm UTC](https://www.ruby-forum.com/t/validate-callback-balks-when-using-ar-find-method/162111/3 "2009-03-05T21:51:43Z")

</div>

Colin L. wrote:

> I do exactly what you describe with no problems. Are you sure you have  
> not just got a typo somewhere that your brain is refusing to see?

Always a possibility. I’ll keep looking. But thanks for the verification  
that it should work.

Other possible extenuating circumstances I realized might be worth  
mentioning:

- this is a 1.2.6 legacy app
- PrivilegedUser is actually a subclass of an abstract class to  
facilitate connecting to multiple databases w/in the same app. However,  
this hasn’t posed any problems anywhere else.

class CountyActiveRecord \< ActiveRecord::Base  
@@county\_domain = Thread.current[:county\_domain]  
self.abstract\_class = true  
establish\_connection("#{RAILS\_ENV}\_#{@@county\_domain}".to\_sym)  
end

class PrivilegedUser \< CountyActiveRecord  
… etc etc…  
end

– gw
