amatsuda/active_decorator

Support for ActionController::API

Closed this issue · 2 comments

This doesn't work with ActionController::API. I added an initializer with this code:

# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

ActiveSupport.on_load(:action_controller) do
  require 'active_decorator/monkey/abstract_controller/rendering'
  ActionController::API.send :prepend, ActiveDecorator::Monkey::AbstractController::Rendering

  require 'active_decorator/monkey/action_controller/base/rescue_from'
  ActionController::API.send :prepend, ActiveDecorator::Monkey::ActionController::Base

  ActionController::API.send :include, ActiveDecorator::ViewContext::Filter
end

Do you think this is enough to support AC::API? I can add it to the project.

I'm sorry I don't use AC::API in my real project, so I don't know if that works.
I'm happy to merge if I get a PR for that patch with a test that passes.

No exceptions so far, I can provide a PR over the weekend. Thanks.