Sha256: 8d3dc5875db7be208e67b51a590393b73d91c16c56f71994a9b960c66d7f934a
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Draper module Compatibility # Draper expects your `ApplicationController` to include `ActionView::Rendering`. The # `ApplicationController` generated by Rails 5 API-only applications (created with # `rails new --api`) don't by default. However, including `ActionView::Rendering` in # `ApplicatonController` breaks `render :json` due to `render_to_body` being overridden. # # This compatibility patch fixes the issue by restoring the original `render_to_body` # method after including `ActionView::Rendering`. Ultimately, including `ActionView::Rendering` # in an ActionController::API may not be supported functionality by Rails (see Rails issue # for more detail: https://github.com/rails/rails/issues/27211). This hack is meant to be a # temporary solution until we can find a way to not rely on the controller layer. module ApiOnly extend ActiveSupport::Concern included do alias_method :previous_render_to_body, :render_to_body include ActionView::Rendering alias_method :render_to_body, :previous_render_to_body end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
draper-4.0.0 | lib/draper/compatibility/api_only.rb |