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:
Gary Gordon
2014-11-04 15:36:52 -05:00
parent 08fbba9087
commit 5560b49098
8 changed files with 99 additions and 50 deletions

View File

@@ -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