ok thanks that got it working.  I think I had this working before like
that, but then changed it because of confusion over the usage of
self.  I thought self was used to define class-level methods.
Apparently the usage is different in instance methods?  It is partly
addressed here

http://wiki.rubyonrails.org/rails/pages/RubyHeadScratching

On Nov 19, 1:56 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On Nov 19, 6:19 pm, Brian <[EMAIL PROTECTED]> wrote:
>
> > thanks for the response, but can anyone provide a simple example of
> > the proper way to access and change an attribute from within an
> > instance method?
>
> You just need to call the accessor methods, same as for people outside
> the class. the only subtlety is that to set it you need to do
> self.attribute_name = value (as attribute_name = value would be
> interpreted as you trying to set a local variable)
>
> Fred
>
> > I've worked through AWDwR, re-read the ActiveRecord and Ruby sections,
> > am currently going through wiki.rubyonrails.org and the Reference
> > Docs, and still haven't found it.
>
> > On Nov 19, 11:55 am, Frederick Cheung <[EMAIL PROTECTED]>
> > wrote:
>
> > > On 19 Nov 2008, at 16:48, Brian wrote:> What's wrong?  I'm assuming I'm 
> > > missing something basic, but it's
> > > > pretty confusing.
>
> > > attributes aren't instance variables
>
> > > Fred
>
> > > > Thanks
--~--~---------~--~----~------------~-------~--~----~
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