Sha256: b6e04ac7206fe712a55655b296fcc2049aed782cb6c4eadb39d001d5a3f90968
Contents?: true
Size: 906 Bytes
Versions: 3
Compression:
Stored size: 906 Bytes
Contents
class TbCore::Responder < ActionController::Responder def initialize(*) super # Don't require a :location parameter for redirecting if !@options.has_key?(:location) @options[:location] = nil end end # Override the common behavior for formats associated with APIs, such as :xml and :json. # def api_behavior raise MissingRenderer.new(format) unless has_renderer? if get? display resource elsif post? || patch? display resource, :status => :created, :location => api_location else head :no_content end end # Default responder only sends the basic errors array # This override also sends the translated labels for convenience # def json_resource_errors return { :errors => resource.errors, :labels => resource.errors.keys.collect{ |attribute| resource.class.human_attribute_name(attribute) } } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tb_core-1.3.9 | lib/tb_core/responder.rb |
tb_core-1.3.7 | lib/tb_core/responder.rb |
tb_core-1.3.6 | lib/tb_core/responder.rb |