Search code examples
ruby-on-railsrubyrabl

Changing the response status code when using rabl


I am building a rails api server with rabl as the json responder. For all the success methods, rabl's default status code is 200 but we have some internally assigned status codes for different scenario. Is there a way to change the status code when sending the response?


Solution

  • if you render your view with respond_with or render methods, you could write:

    render @something, status: 400
    
    respond_with @smething, status: 400
    

    rabl - just templating system for rendering resources