Dumb question: what is attr_xxxx


#1

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.


#2

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:
http://www.rubycentral.com/book/.

“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,
Erik.

Josh K. schreef: