wtorek, 28 czerwca 2011

UPDATE Rails 3.1: respond_with i pusty json/xml/yaml przy update

Update postu Rails3: respond_with i pusty json/xml/yaml przy update dla Rails 3.1. Plik application_responder.rb powinien w niej wyglądać tak:

# /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