开发者

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

开发者 https://www.devze.com 2023-03-01 15:26 出处:网络
By default, an activerecord model has attr_accessor for all the 开发者_JAVA百科table columns correct?No, this is not correct. An active record object will have getter and setter methods for all column

By default, an activerecord model has attr_accessor for all the 开发者_JAVA百科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.

0

精彩评论

暂无评论...
验证码 换一张
取 消