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
# /lib/application_responder.rb | |
class ApplicationResponder < ActionController::Responder | |
def api_behavior(error) | |
raise error unless resourceful? | |
if get? | |
display resource | |
elsif post? | |
display resource, status: :created, location: api_location | |
elsif put? | |
display resource, status: :ok, location: api_location | |
elsif has_empty_resource_definition? | |
display empty_resource, status: :ok | |
else | |
head :ok | |
end | |
end | |
end |
Reszta pozostaje bez zmian.
Brak komentarzy:
Prześlij komentarz