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

Upgrading from 0.3.1 to 0.4.0 breaks Renderer #105

Open
austinh opened this issue Mar 18, 2019 · 3 comments
Open

Upgrading from 0.3.1 to 0.4.0 breaks Renderer #105

austinh opened this issue Mar 18, 2019 · 3 comments

Comments

@austinh
Copy link

austinh commented Mar 18, 2019

Hello, I recently tried to upgrade jsonapi-rails from 0.3.1 to 0.4.0 and I get the following error anywhere I call JSONAPI::Serializable::Renderer.new with the exact same params as before:

no implicit conversion of nil into Hash

Note: I am also using this in conjunction with https://github.com/jsonapi-suite/jsonapi_compliable

@austinh austinh changed the title Upgrading fro 0.3.1 to 0.4.0 breaks Upgrading fro 0.3.1 to 0.4.0 breaks Renderer Mar 18, 2019
@austinh austinh changed the title Upgrading fro 0.3.1 to 0.4.0 breaks Renderer Upgrading from 0.3.1 to 0.4.0 breaks Renderer Mar 18, 2019
@amaierhofer
Copy link

Where exactly does this error occur? I had troubles too because I was overriding jsonapi_pagination, returning nil for for non index actions. Version 0.3.1 accepted nil return values but 0.4.0 did not. The stacktrace I got was as follows

TypeError: no implicit conversion of nil into Hash
    jsonapi-rails (0.4.0) lib/jsonapi/rails/renderer.rb:28:in `merge!'

@ferrisoxide
Copy link

Seems to be the case. I had the same issue (no implicit conversion of nil into Hash) and had to return an empty hash in jsonapi_pagination on non-index/non-paginated data. Thanks @amaierhofer.

@jerko-culina
Copy link

jerko-culina commented May 7, 2020

I have same issue too. Below is more details:
Rails 5.2.4.2

    28: def render_data_japi(data, opts)
 => 29:   binding.pry
    30:   render opts.merge(
    31:     jsonapi: data,
    32:     class: serializable_class
    33:   )
    34: end

[1] pry(#<Api::V2::TranslationsController>)> render opts.merge(
[1] pry(#<Api::V2::TranslationsController>)*   jsonapi: data,
[1] pry(#<Api::V2::TranslationsController>)*   class: serializable_class
[1] pry(#<Api::V2::TranslationsController>)*     )
I, [2020-05-07T04:07:03.451683 #77626]  INFO -- : Completed JSON API rendering (12.8ms)
NoMethodError: undefined method `[]' for Api::V2::SerializableTranslation:Class
from .../.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/jsonapi-serializable-0.3.1/lib/jsonapi/serializable.rb:27:in `resource_for'
[2] pry(#<Api::V2::TranslationsController>)>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants