mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Allow overriding the adapter with render option
Make it easy to use multiple adapters in an app. use "adapter: false" to not use ams make a test override config.adapter
This commit is contained in:
@@ -25,13 +25,9 @@ module ActionController
|
||||
end
|
||||
|
||||
def render_using_custom_root_in_adapter_with_a_default
|
||||
old_adapter = ActiveModel::Serializer.config.adapter
|
||||
# JSON-API adapter sets root by default
|
||||
ActiveModel::Serializer.config.adapter = ActiveModel::Serializer::Adapter::JsonApi
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
render json: @profile, root: "profile"
|
||||
ensure
|
||||
ActiveModel::Serializer.config.adapter = old_adapter
|
||||
render json: @profile, root: "profile", adapter: :json_api
|
||||
end
|
||||
|
||||
def render_array_using_implicit_serializer
|
||||
|
||||
Reference in New Issue
Block a user