mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
c53c418e6f
Related to #39495. For now, `read_attribute`, `write_attribute`, `[]`, `[]=` are aware of attribute aliases, but `has_attribute?` is not. It will easily miss attribute alias resolution before using `has_attribute?`, it is very inconvenient. I think the inconvenience is not intended, so `has_attribute?` should be aware of attribute aliases like as others for consistency.
24 lines
593 B
Ruby
24 lines
593 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ActiveRecord #:nodoc:
|
|
# = Active Record \Serialization
|
|
module Serialization
|
|
extend ActiveSupport::Concern
|
|
include ActiveModel::Serializers::JSON
|
|
|
|
included do
|
|
self.include_root_in_json = false
|
|
end
|
|
|
|
def serializable_hash(options = nil)
|
|
if self.class._has_attribute?(self.class.inheritance_column)
|
|
options = options ? options.dup : {}
|
|
|
|
options[:except] = Array(options[:except]).map(&:to_s)
|
|
options[:except] |= Array(self.class.inheritance_column)
|
|
end
|
|
|
|
super(options)
|
|
end
|
|
end
|
|
end
|