From 4a8f0816db3a2f3709a61a266280c51ead434d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Emin=20=C4=B0NA=C3=87?= Date: Mon, 27 Apr 2015 15:44:35 +0300 Subject: Add note about sti column value to becomes method [ci skip] --- activerecord/lib/active_record/persistence.rb | 6 ++++-- 1 file 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 partial: @client.becomes(Company) 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) -- cgit v1.2.3