Created
November 13, 2012 16:00
-
-
Save lxcodes/4066569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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