26 lines
677 B
Ruby
26 lines
677 B
Ruby
module Locomotive
|
|
class AdminResponder < ::ActionController::Responder
|
|
|
|
include Responders::FlashResponder
|
|
|
|
def api_behavior(error)
|
|
raise error unless resourceful?
|
|
|
|
# generate flash messages
|
|
set_flash_message!
|
|
|
|
if get?
|
|
display resource
|
|
elsif has_errors?
|
|
display({ :errors => resource.errors, :alert => flash[:alert] }, :status => :unprocessable_entity)
|
|
elsif post?
|
|
display resource, :status => :created, :location => resource_location
|
|
else
|
|
display({ :notice => controller.flash[:notice] })
|
|
end
|
|
|
|
controller.flash.discard # reset flash messages !
|
|
end
|
|
|
|
end
|
|
end |