Commit 706f6644 by liyijie

增加simple_controller对于json_resource_errors的内容

parent 6c17d9a4
......@@ -5,6 +5,7 @@ require 'responders'
require 'ransack'
require 'inherited_resources'
require 'pundit'
require 'simple_controller/responder'
module SimpleController
autoload :VERSION, 'simple_controller/version'
......
class SimpleController::BaseController < ::InheritedResources::Base
include Pundit
self.responder = SimpleController::Responder
respond_to :json
rescue_from Pundit::NotAuthorizedError do |e|
......@@ -181,7 +183,7 @@ class SimpleController::BaseController < ::InheritedResources::Base
end
def end_of_association_chain
after_association_chain(policy_association_chain.order(id: :desc))
after_association_chain(policy_association_chain).order(id: :desc)
end
def collection
......
class SimpleController::Responder < ActionController::Responder
include Responders::FlashResponder
include Responders::HttpCacheResponder
def json_resource_errors
{ errors: resource.errors, message: resource.errors.map { |error| error.message}.join('\n') }
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment