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

Add Rails >= 5.0.beta3 JSON API params parsing #1747

Merged
merged 1 commit into from
May 26, 2016

Conversation

bf4
Copy link
Member

@bf4 bf4 commented May 23, 2016

data = { :_json => data } unless data.is_a?(Hash)
data.with_indifferent_access
end
ActiveModelSerializers::Jsonapi.install

# ref https://github.com/rails/rails/pull/21496
ActionController::Renderers.add :jsonapi do |json, options|
Copy link
Contributor

Choose a reason for hiding this comment

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

line 72 is where travis is failing. media_type undefined

@remear
Copy link
Member

remear commented May 24, 2016

I'm handling this PR. For now, hold off on reviewing further.

# actionpack/lib/action_dispatch/http/mime_types.rb
Mime::Type.register MEDIA_TYPE, :jsonapi

mime_type = Mime::Type.lookup(MEDIA_TYPE)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is equivalent to mime_type = Mime[MEDIA_TYPE].

@remear remear force-pushed the fix_jsonapi_mime_registration branch from c1be9e8 to ea06d3c Compare May 26, 2016 04:09
def self.install
# actionpack/lib/action_dispatch/http/mime_types.rb
Mime::Type.register MEDIA_TYPE, :jsonapi
mime_type = Mime::Type.lookup(MEDIA_TYPE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not Mime[:jsonapi]?

Copy link
Member

Choose a reason for hiding this comment

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

At the time it seemed like this didn't work the same between Rails 4.x and 5. I went tried again this morning it works just fine.

@remear remear force-pushed the fix_jsonapi_mime_registration branch 2 times, most recently from bff3176 to eec7750 Compare May 26, 2016 16:07
@remear remear force-pushed the fix_jsonapi_mime_registration branch from eec7750 to bfd0bf4 Compare May 26, 2016 16:12
@remear remear merged commit 8a3196d into master May 26, 2016
@remear remear deleted the fix_jsonapi_mime_registration branch May 26, 2016 16:55
@remear remear restored the fix_jsonapi_mime_registration branch May 26, 2016 17:15
@remear remear deleted the fix_jsonapi_mime_registration branch May 26, 2016 20:22
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.

4 participants