Forum: Ruby on Rails dumb question: what is attr_xxxx

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Josh K. (Guest)
on 2006-03-31 09:09
i'm very new to the rails scene and am seeing lines of code like
attr_reader, attr_writer, attr_accessor, etc... and have no idea what
they do. reading the section in the book i'm reading that explains the
previous block of code says nothing about it really.
Erik van Oosten (Guest)
on 2006-03-31 10:32
(Received via mailing list)
I can recommend reading up on your Ruby syntax. The pick axe book is an
good start. Its for sale in any bookshop but also on-line here:

"attr_reader" is a method that will generate an instance variable, and a
reader (a.k.a. getter) for it in your class. The others also create
setters, etc.

Have fun,

Josh K. schreef:
This topic is locked and can not be replied to.