# After\_find gets called for a model and not for other

**URL:** <https://www.ruby-forum.com/t/after-find-gets-called-for-a-model-and-not-for-other/48219>\
**Category:** Rails\
**Created:** [November 17, 2005, 9:11pm UTC](https://www.ruby-forum.com/t/after-find-gets-called-for-a-model-and-not-for-other/48219 "2005-11-17T21:11:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eduardo.fernandez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/cdc98d/32.png) [@eduardo.fernandez](https://www.ruby-forum.com/u/eduardo.fernandez)\
**Post date:** [November 17, 2005, 9:11pm UTC](https://www.ruby-forum.com/t/after-find-gets-called-for-a-model-and-not-for-other/48219/1 "2005-11-17T21:11:06Z")

</div>

Hello,

I have two models in my app with after\_find defined.

One does get called and the other does not.

I have double checked and they are both defined private and correctly I  
think.

Is there anything in a model that determines if after\_find gets called  
or not?

I am using the latest RC.

## Thanks in advance.

Eduardo Fernández Corrales

---

<div class="post-metadata">

**Author:** ![eduardo.fernandez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/cdc98d/32.png) [@eduardo.fernandez](https://www.ruby-forum.com/u/eduardo.fernandez)\
**Post date:** [November 17, 2005, 9:17pm UTC](https://www.ruby-forum.com/t/after-find-gets-called-for-a-model-and-not-for-other/48219/2 "2005-11-17T21:17:08Z")

</div>

On Friday 18 November 2005 03:09, Eduardo Fernandez C. wrote:

> Hello,
> 
> I have two models in my app with after\_find defined.  
> It would help if you could post related code sample somewhere, so  
> there’s more chance you’ll get an answer.

---

<div class="post-metadata">

**Author:** ![eduardo.fernandez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/cdc98d/32.png) [@eduardo.fernandez](https://www.ruby-forum.com/u/eduardo.fernandez)\
**Post date:** [November 17, 2005, 10:47pm UTC](https://www.ruby-forum.com/t/after-find-gets-called-for-a-model-and-not-for-other/48219/3 "2005-11-17T22:47:43Z")

</div>

Well, here is the model that does not get called back:

class PartidoEquipo \< ActiveRecord::Base  
attr\_accessor :base

belongs\_to :equipo  
belongs\_to :partido  
belongs\_to :tactica\_ataque, :class\_name =\> “Tactica”, :foreign\_key  
=\> “tactica\_ataque”  
belongs\_to :tactica\_defensa, :class\_name =\> “Tactica”, :foreign\_key  
=\> “tactica\_defensa”  
belongs\_to :base\_titular, :class\_name =\> “PartidoJugador”,  
:foreign\_key =\> “base\_titular”

private  
def after\_find  
@base = base\_titular  
loger.info(“En PartidoEquipo.after\_find”)  
end

end

Sorry about the spanish.

I think there is nothing special to that code, that’s why I didn’t post  
it. :-p

On 11/17/05, Dmitry V. Sabanin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Eduardo Fernández Corrales

---

<div class="post-metadata">

**Author:** ![eduardo.fernandez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/cdc98d/32.png) [@eduardo.fernandez](https://www.ruby-forum.com/u/eduardo.fernandez)\
**Post date:** [November 17, 2005, 11:54pm UTC](https://www.ruby-forum.com/t/after-find-gets-called-for-a-model-and-not-for-other/48219/4 "2005-11-17T23:54:39Z")

</div>

On Nov 17, 2005, at 2:44 PM, Eduardo Fernandez C. wrote:

> =\> “tactica\_defensa”
> 
> Sorry about the spanish.
> 
> I think there is nothing special to that code, that’s why I didn’t  
> post it. :-p

Well there is one thing:

loger.info("…")

Ought that to be

logger.info("…")

?

- Jamis

---

<div class="post-metadata">

**Author:** ![eduardo.fernandez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/cdc98d/32.png) [@eduardo.fernandez](https://www.ruby-forum.com/u/eduardo.fernandez)\
**Post date:** [November 18, 2005, 12:06am UTC](https://www.ruby-forum.com/t/after-find-gets-called-for-a-model-and-not-for-other/48219/5 "2005-11-18T00:06:43Z")

</div>

On 11/17/05, Jamis B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

\<\> - Jamis

> 

Jamis, you are right. It should be logger.info.

However, in the console when loading a model with find, that method  
didn’t fail with a NameError. The method is not being called back.

I corrected the mistake but no changes.

## Weird.

Eduardo Fernández Corrales
