diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-04-18 13:01:16 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-04-18 13:03:51 +0200 |
commit | 228559eab8e50dd52e1f07841a288ed39c84ff4e (patch) | |
tree | e4a2a2bf1ae7f1ac988ead679a076c4211a557aa /activerecord | |
parent | 154e13c00b497d22e294cddb1a1657ffe38eea1c (diff) | |
parent | 8f7d9eb043dbbca9e4b424c77e643312a9927eac (diff) | |
download | rails-228559eab8e50dd52e1f07841a288ed39c84ff4e.tar.gz rails-228559eab8e50dd52e1f07841a288ed39c84ff4e.tar.bz2 rails-228559eab8e50dd52e1f07841a288ed39c84ff4e.zip |
Merge pull request #19787 from Senjai/patch-2
[Doc] Encourage users to user super to override methods.
[ci skip]
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 67490ecd97..9c5b7d937d 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -120,23 +120,22 @@ module ActiveRecord #:nodoc: # All column values are automatically available through basic accessors on the Active Record # object, but sometimes you want to specialize this behavior. This can be done by overwriting # the default accessors (using the same name as the attribute) and calling - # <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually - # change things. + # +super+ to actually change things. # # class Song < ActiveRecord::Base # # Uses an integer of seconds to hold the length of the song # # def length=(minutes) - # write_attribute(:length, minutes.to_i * 60) + # super(minutes.to_i * 60) # end # # def length - # read_attribute(:length) / 60 + # super / 60 # end # end # # You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt> - # instead of <tt>write_attribute(:attribute, value)</tt> and <tt>read_attribute(:attribute)</tt>. + # or <tt>write_attribute(:attribute, value)</tt> and <tt>read_attribute(:attribute)</tt>. # # == Attribute query methods # |