GithubHelp home page GithubHelp logo

Comments (4)

richmolj avatar richmolj commented on August 10, 2024

I'm not totally opposed to adding "out of the box" support, but currently I think users can do this on their own:

def destroy
  post = Post.find(1)
  if post.destroy
    render jsonapi: nil, meta: { foo: 'bar' }, status: 200
    # or
    return head(:no_content)
  else
    render_errors_for(post)
  end
end

Would that work for you?

from jsonapi_compliable.

klobuczek avatar klobuczek commented on August 10, 2024

Yes. That's what I ended up doing. I was just confused since the documentation suggested calling render_jsonapi on the destroyed object which is the rails way, but I could not find anything corresponding in the code.

from jsonapi_compliable.

richmolj avatar richmolj commented on August 10, 2024

Yep, I think it's really whether or not you prefer the Rails default or pure compliance. The docs could definitely be improved here.

from jsonapi_compliable.

daniel-sullivan avatar daniel-sullivan commented on August 10, 2024

Just in case anyone comes across this via Google (it's the top result for 'render_jsonapi status', it is possible to set the return status from the render_jsonapi method itself by:

render_jsonapi company, scope: false, status: 201

It's not possible to use: render jsonapi: company, status: 201 if you are relying on the @context variable in any of your serializers as this is set and passed by render_jsonapi

from jsonapi_compliable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.