There are times when using jsonapi-resources that you will need to write your own controller actions because you have complicated logic or a resource with relationships to process in a single transactioned request. It's nice to know how to handle the success and failure responses in a JSONAPI compliant manner. Thankfully jsonapi-resources exposes these features to us, you just need to read some code to figure out how to use them.
Consider a use-case where you are updating a Users
model and its collection of assigned Roles
. Say you author an action in your users_controller.rb
named update_user_and_roles
:
def update_user_and_roles