Resting Pug logo Resting Pug

Description

Renders error when required params are missing

Tip

Override this method to add more complicated logic of rendering.

Used in

Example

class BooksController < ApplicationController
  include RestingPug::Base

  private
  # Override a render_param_missing to render with status 422
  def render_param_missing
    render json: { errors: { subject_model_sym => ['param is missing'] } }, status: 422
  end
end

Source code

# lib/resting_pug/render.rb

def render_param_missing
  render json: { errors: { subject_model_sym => ['param is missing'] } }, status: 400
end
Find me on GitHub