If you want to use the Draper gem together with Decent Exposure, you can use the following strategy:
class DecoratorStrategy < DecentExposure::ActiveRecordWithEagerAttributesStrategy def resource r = super.tap { |r| r.class.send(:include, Draper::Decoratable) unless r.respond_to?(:decorate) } r.decorate end end
class UsersController < ApplicationController expose :user, strategy: DecoratorStrategy end
It uses the default strategy (ActiveRecordWithEagerAttributesStrategy) and does two things on top of it:
ActiveRecordWithEagerAttributesStrategy
Draper::Decoratable
.decorate
decent exposure
There was an error while loading. Please reload this page.