mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Reset base_class when the model class is duped or cloned
This commit is contained in:
parent
7abd9b5f66
commit
8c580d716f
1 changed files with 13 additions and 0 deletions
|
@ -215,6 +215,19 @@ module ActiveRecord
|
|||
super
|
||||
end
|
||||
|
||||
def dup # :nodoc:
|
||||
# `initialize_dup` / `initialize_copy` don't work when defined
|
||||
# in the `singleton_class`.
|
||||
other = super
|
||||
other.set_base_class
|
||||
other
|
||||
end
|
||||
|
||||
def initialize_clone(other) # :nodoc:
|
||||
super
|
||||
set_base_class
|
||||
end
|
||||
|
||||
protected
|
||||
# Returns the class type of the record using the current module as a prefix. So descendants of
|
||||
# MyApp::Business::Account would appear as MyApp::Business::AccountSubclass.
|
||||
|
|
Loading…
Reference in a new issue