Comments (4)
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.
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.
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.
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)
- no object in Resource HOT 6
- Add before_commit_abort hook
- Add a rollback method on resources to handle manually defining a transaction HOT 2
- N+1 Query Detected
- N+1 Query with Bullet HOT 1
- Detect N+1 Query
- Association arguments and scope HOT 1
- Pass in config to adapters HOT 3
- Add association validation errors on unsuccessful sidepost
- Posting to nested routes HOT 5
- Attributes/Persistence logic does not support Mongoid HABTM HOT 2
- Attributes/Persistence not friendly to noSQL embedding HOT 4
- Sideloading fails if (nested) sideloads have the same name HOT 1
- Need to declare jsonapi resource: in every controller when inheriting mix-in from ApplicationController HOT 1
- No interface to discriminently disable pagination for resource HOT 3
- Sequel adapter HOT 3
- Sideloading / include no longer works in newest version HOT 2
- having filter guards call controller method causes issues when resource is sideloaded HOT 1
- Disassociating a required belongs_to should raise error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonapi_compliable.