By default, an activerecord model has attr_accessor for all the table columns correct?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With