mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
parent
7b86838fa6
commit
a1755c5b27
16
lib/active_record/serializer_override.rb
Normal file
16
lib/active_record/serializer_override.rb
Normal file
@ -0,0 +1,16 @@
|
||||
# We do not recommend that you use AM::S in this way, but if you must, here
|
||||
# is a mixin that overrides ActiveRecord::Base#to_json and #as_json.
|
||||
|
||||
module ActiveRecord
|
||||
module SerializerOverride
|
||||
def to_json options = {}
|
||||
active_model_serializer.new(self).to_json options
|
||||
end
|
||||
|
||||
def as_json options={}
|
||||
active_model_serializer.new(self).as_json options
|
||||
end
|
||||
end
|
||||
|
||||
Base.send(:include, SerializerOverride)
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user