Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

By default, an activerecord model has attr_accessor for all the table columns correct?

By default, an activerecord model has attr_accessor for all the table columns correct?

like image 704
Blankman Avatar asked Apr 28 '11 20:04

Blankman


1 Answers

No, this is not correct. An active record object will have getter and setter methods for all columns, but these are not defined using attr_accessor nor do they act like ones that are defined using attr_accessor:

While the getters and setters defined by attr_accessor get and set instance variables, the getters and setters on an active record objects get and set values in the @attributes hash, which every active record object has.

like image 149
sepp2k Avatar answered Oct 03 '22 12:10

sepp2k