After_find gets called for a model and not for other

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

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.

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 [email protected] wrote:


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Eduardo Fernández Corrales

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

On 11/17/05, Jamis B. [email protected] 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