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.
66d1d0df01e4bbb82674a353ea68d6ee?d=identicon&s=25 Josh Kieschnick (jjkiesch)
on 2006-03-31 07: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.
22ff4abebc9bfd299524bb14449d95dc?d=identicon&s=25 Erik van Oosten (Guest)
on 2006-03-31 08: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 Kieschnick schreef:
This topic is locked and can not be replied to.