Eduardo Fernandez Corrales
2005-Nov-17 20:09 UTC
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
Dmitry V. Sabanin
2005-Nov-17 20:11 UTC
Re: after_find gets called for a model and not for other
On Friday 18 November 2005 03:09, Eduardo Fernandez Corrales 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. -- Dmitry V. Sabanin http://sabanin.ru
Eduardo Fernandez Corrales
2005-Nov-17 21:44 UTC
Re: after_find gets called for a model and not for other
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 <dmitry-udXvT7TW+8wvJsYlp49lxw@public.gmane.org> wrote:> On Friday 18 November 2005 03:09, Eduardo Fernandez Corrales 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. > > -- > Dmitry V. Sabanin > http://sabanin.ru > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Eduardo Fernández Corrales
On Nov 17, 2005, at 2:44 PM, Eduardo Fernandez Corrales wrote:> 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. :-pWell there is one thing: loger.info("...") Ought that to be logger.info("...") ? - Jamis> > On 11/17/05, Dmitry V. Sabanin <dmitry-udXvT7TW+8wvJsYlp49lxw@public.gmane.org> wrote: >> On Friday 18 November 2005 03:09, Eduardo Fernandez Corrales 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. >> >> -- >> Dmitry V. Sabanin >> http://sabanin.ru >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Eduardo Fernández Corrales > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Eduardo Fernandez Corrales
2005-Nov-17 23:04 UTC
Re: after_find gets called for a model and not for other
On 11/17/05, Jamis Buck <jamis-uHoyYlH2B+GakBO8gow8eQ@public.gmane.org> wrote:> > Well there is one thing: > > loger.info("...") > > Ought that to be > > logger.info("...") > > ? ><> - 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