Skip to content

Instantly share code, notes, and snippets.

@lxcodes
Created November 13, 2012 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lxcodes/4066569 to your computer and use it in GitHub Desktop.
Save lxcodes/4066569 to your computer and use it in GitHub Desktop.
class AppResponder < ActionController::Responder
def to_format
if get? && !resource
controller.response.status = :not_found
elsif has_errors?
controller.response.status = :unprocessable_entity
elsif post?
controller.response.status = :created
end
super
end
end
require 'rabl_responder'
class ApplicationController < ActionController::Base
self.responder = RablResponder
respond_to :json, :xml
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment