Forum: Ruby on Rails after_find gets called for a model and not for other

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
08c61efb47d4b99e8b0b52b10aec3910?d=identicon&s=25 eduardo.fernandez (Guest)
on 2005-11-17 21:11
(Received via mailing list)
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
Fdc7ff1d176325ed86c81c7c4584f0ad?d=identicon&s=25 dmitry (Guest)
on 2005-11-17 21:17
(Received via mailing list)
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.
08c61efb47d4b99e8b0b52b10aec3910?d=identicon&s=25 eduardo.fernandez (Guest)
on 2005-11-17 22:47
(Received via mailing list)
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@sabanin.ru> wrote:
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Eduardo Fernández Corrales
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 jamis (Guest)
on 2005-11-17 23:54
(Received via mailing list)
On Nov 17, 2005, at 2:44 PM, Eduardo Fernandez Corrales 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
08c61efb47d4b99e8b0b52b10aec3910?d=identicon&s=25 eduardo.fernandez (Guest)
on 2005-11-18 00:06
(Received via mailing list)
On 11/17/05, Jamis Buck <jamis@37signals.com> 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
This topic is locked and can not be replied to.