Re: Calling a method on class creation

eggie5
Fri, 24 Aug 2007 19:58:08 -0000

sorry I didn''t see you solution till after I tried accessor method.

Regarding the foreign_key and class_name things, rails was warning me
that if I could, I should specify them to avoid confusion. Since it
was not big deal I just put them in. It''s the least I could do for
ActiveRecord!

On Aug 24, 12:09 pm, "Adam Cohen"
<bionicboo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> On 8/24/07, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
>
>
>
> > THANKS! that''s the trick I was looking for. Now this reminds
me of an
> > example from the essential rails book...
>
> > So, it looks like status is called automatically when a new instance
> > of the class is created?
>
> does defining an after_initialize method not work for you?
>
> by the way, your belongs_to method doesn''t need the :class_name or
> :foreign_key specifications.. These can be inferred from the
> association itself.
>
> Adam