aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-04-27 15:44:35 +0300
committerMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-04-27 15:44:35 +0300
commit4a8f0816db3a2f3709a61a266280c51ead434d58 (patch)
treefd10338afaca272f464809fa2b92417c3bb14a03 /activerecord
parentf00554a8226b9529c38be1f3e61b6b1888682fb4 (diff)
downloadrails-4a8f0816db3a2f3709a61a266280c51ead434d58.tar.gz
rails-4a8f0816db3a2f3709a61a266280c51ead434d58.tar.bz2
rails-4a8f0816db3a2f3709a61a266280c51ead434d58.zip
Add note about sti column value to becomes method [ci skip]
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/persistence.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index ae1c326d95..04ee892eba 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -204,8 +204,10 @@ module ActiveRecord
# like render <tt>partial: @client.becomes(Company)</tt> to render that
# instance using the companies/company partial instead of clients/client.
#
- # Note: The new instance will share a link to the same attributes as the original class.
- # So any change to the attributes in either instance will affect the other.
+ # Note: The new instance will share a link to the same attributes as the original class
+ # therefore sti column value will be same with the original object.
+ # If you want sti column to be changed, use +becomes!+ instead.
+ # Any change to the attributes in either instance will affect the other.
def becomes(klass)
became = klass.new
became.instance_variable_set("@attributes", @attributes)