开发者

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 开发者_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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜