-
Notifications
You must be signed in to change notification settings - Fork 141
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
deserialize_jsonapi not found on controller #10
Comments
Yes, this is my fault for not keeping the docs up to date. I've been working on the client-side recently - now that that's wrapped up we can focus on maintenance and you hopefully won't see issues like this again :) I'll have everything updated (with a full-stack sample application) this weekend, but for now, here's an example controller. Mostly just replace the deserialization with class EmployeesController < ApplicationController
jsonapi resource: EmployeeResource
strong_resource :employee do
has_many :positions, destroy: true do
belongs_to :department, destroy: true
end
end
before_action :apply_strong_params, only: [:create, :update]
def create
employee, success = jsonapi_create.to_a
if success
render_jsonapi(employee, scope: false)
else
render_errors_for(employee)
end
end
def update
employee, success = jsonapi_update.to_a
if success
render_jsonapi(employee, scope: false)
else
render_errors_for(employee)
end
end
def destroy
employee = Employee.find(params[:id])
employee.destroy
render_jsonapi(employee, scope: false)
end
end |
For an up-to-date sample application and in-depth examples: https://gist.github.com/richmolj/c7f1adca75f614bb71b27f259ff3c37a |
@BastianL main documentation site is updated, please confirm this all now makes sense 😄 |
Accomodate JSON, Array, escaped string params
I'm having trouble during a
patch
with strong_resources. The guides say I should addbefore_action :deserialize_jsonapi!, only: [:create, :update]
in order for puts/creates to work properly (makes sense). However this method doesn't seem to exist, and I didn't find it in the code.Is this due to out of date docs? Thanks.
The text was updated successfully, but these errors were encountered: