Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding the adapter with render option #718

Merged
merged 1 commit into from
Nov 13, 2014

Conversation

ggordon
Copy link
Contributor

@ggordon ggordon commented Nov 5, 2014

Renamed config.adapter to config.default_adapter
Undid the rename, this request is just for the adapter option to render now.

@kurko
Copy link
Member

kurko commented Nov 6, 2014

Can you elaborate on why you think this change is important?

@ggordon
Copy link
Contributor Author

ggordon commented Nov 6, 2014

I need a method to use multiple adapters in an app. Version 2 on my API uses the json adapter and version 3 will use json_api. I didn't see an easier way to do that.

Or were you referring to the 'default_adapter' bit? It just made it seem less constant, I can take that part out easily enough.

@ggordon ggordon force-pushed the adapter_override branch 2 times, most recently from efb02d1 to e61bc08 Compare November 12, 2014 19:41
@kurko
Copy link
Member

kurko commented Nov 12, 2014

Summoning @steveklabnik.

@steveklabnik
Copy link
Contributor

Conceptually, this seems legit. I don't mind letting people override adapters in the controller like this.

@guilleiguaran
Copy link
Member

Agree with @steveklabnik, sounds legit in my opinion

@kurko
Copy link
Member

kurko commented Nov 13, 2014

@ggordon could you fix the broken tests please?

@ggordon
Copy link
Contributor Author

ggordon commented Nov 13, 2014

@kurko Fixed and rebased.

yield
ensure
ActiveModel::Serializer.config.adapter = old_adapter
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ggordon you're testing the adapter: :json_api option everywhere. We want to still not need to put it, but use a default adapter and override only where need.

Could you leave some tests where JSONAPI is the default adapter and you don't pass the adapter: :json_api? We need to assert that :json_api as default adapter will work.

@ggordon
Copy link
Contributor Author

ggordon commented Nov 13, 2014

@kurko No problem.

Make it easy to use multiple adapters in an app.

use "adapter: false" to not use ams

make a test override config.adapter
@ggordon
Copy link
Contributor Author

ggordon commented Nov 13, 2014

It's not obvious from the commit, but serialization_test.rb still includes a test that sets config.adapter to :json_api instead of the adapter option.

kurko added a commit that referenced this pull request Nov 13, 2014
Allow overriding the adapter with render option
@kurko kurko merged commit c53f1da into rails-api:master Nov 13, 2014
@ggordon
Copy link
Contributor Author

ggordon commented Nov 13, 2014

@kurko Thanks for merging!

@ggordon ggordon deleted the adapter_override branch November 13, 2014 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants