cannot define multiple schemas in one controller (safe params)
gotar opened this issue · 1 comments
gotar commented
Describe the bug
If schema is defined more than once, it overwrite safe_params. So safe_params are only available and works for last defined schema.
To Reproduce
class UsersController < ApplicationController
schema(:show) do
required(:id).value(:integer)
end
schema(:new) do
required(:id).value(:integer)
end
def show
if safe_params.success?
render json: {id: safe_params[:id], name: "Jane"}
else
render json: {errors: safe_params.errors.to_h}
end
end
def new
if safe_params.success?
render json: {id: safe_params[:id], name: "Jane"}
else
render json: {errors: safe_params.errors.to_h}
end
end
end
Expected behavior
safe params works for both defined schema, currently second works, but for :show
safe_params are just nil