mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #41992 from ashiksp/update-sti-abbreviation
[ci skip]Updated abbreviation for single table inheritance.
This commit is contained in:
commit
10f031f704
2 changed files with 7 additions and 7 deletions
|
@ -584,17 +584,17 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
# Returns an instance of the specified +klass+ with the attributes of the
|
||||
# current record. This is mostly useful in relation to single-table
|
||||
# inheritance structures where you want a subclass to appear as the
|
||||
# current record. This is mostly useful in relation to single table
|
||||
# inheritance (STI) structures where you want a subclass to appear as the
|
||||
# superclass. This can be used along with record identification in
|
||||
# Action Pack to allow, say, <tt>Client < Company</tt> to do something
|
||||
# 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.
|
||||
# Therefore the sti column value will still be the same.
|
||||
# Therefore the STI column value will still be the same.
|
||||
# Any change to the attributes on either instance will affect both instances.
|
||||
# If you want to change the sti column as well, use #becomes! instead.
|
||||
# If you want to change the STI column as well, use #becomes! instead.
|
||||
def becomes(klass)
|
||||
became = klass.allocate
|
||||
|
||||
|
@ -609,11 +609,11 @@ module ActiveRecord
|
|||
became
|
||||
end
|
||||
|
||||
# Wrapper around #becomes that also changes the instance's sti column value.
|
||||
# Wrapper around #becomes that also changes the instance's STI column value.
|
||||
# This is especially useful if you want to persist the changed class in your
|
||||
# database.
|
||||
#
|
||||
# Note: The old instance's sti column value will be changed too, as both objects
|
||||
# Note: The old instance's STI column value will be changed too, as both objects
|
||||
# share the same set of attributes.
|
||||
def becomes!(klass)
|
||||
became = becomes(klass)
|
||||
|
|
|
@ -162,7 +162,7 @@ class DestroyAssociationAsyncTest < ActiveRecord::TestCase
|
|||
BookDestroyAsync.delete_all
|
||||
end
|
||||
|
||||
test "has_many with sti parent class destroys all children class records" do
|
||||
test "has_many with STI parent class destroys all children class records" do
|
||||
book = BookDestroyAsync.create!
|
||||
LongEssayDestroyAsync.create!(book: book)
|
||||
ShortEssayDestroyAsync.create!(book: book)
|
||||
|
|
Loading…
Reference in a new issue