Maybe this is useful

http://forums.site5.com/showthread.php?t=18522

On 30 авг, 06:44, Colin Law <[email protected]> wrote:
> 2009/8/30 Frederick Cheung <[email protected]>:
>
>
>
>
>
> > On 30 Aug 2009, at 09:17, Colin Law wrote:
>
> >> 2009/8/30 CoolAJ86 <[email protected]>:
>
> >>>> Well yes - you still need to write the accessor methods to store you
> >>>> instance variables (attr_accessor is probably enough).
>
> >>>> Fred
>
> >>> That makes sense. Thanks.
>
> >>> I had my JavaScript thinking cap on when I was doing this... thinking
> >>> to create accessors out of thin air.
>
> >>> I also just found out that the virtual accessors are accessors, not
> >>> class variables.
> >>> return @updated_at # always null
> >>> return updated_at # works
>
> >> Don't understand this.
>
> > I think what the previous poster has realised is that activerecord
> > attributes are not stored inside individual instance variables.
>
> Ah, yes
>
> Colin
>
>
>
> > Fred
> >> As I understand it if you have
> >> attr_accessor :my_var
> >> then @my_var will access the variable (but this may only be written
> >> inside the class)
> >> and my_var is a method (well two methods actually) that may be used
> >> externally to read/write to @my_var so you can say
> >> my_object.my_var = 1
> >> x = my_object.my_var
>
> >> If you use my_var (no @) inside the class this should work but it is
> >> calling the accessor methods rather than directly accessing @my_var
>
> >> Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to