draper
draper copied to clipboard
Draper::UninferrableDecoratorError while decorating Delayed::Job
I just tried to decorate Delayed::Job but unfortunately it does not work.
My environment:
- Rails 5.0.0.1
- draper 3.0.0.pre1
- delayed_job 4.1.2
- delayed_job_active_record 4.1.1
My code:
decorators/delayed/job_decorator.rb
class Delayed::JobDecorator < Draper::Decorator
delegate_all
def status
'queued'
end
end
Admin::DiagnosticsController#index
@mailer_service = Delayed::Job.where("handler LIKE :service", service: '%SendClientSummaryJob%').first.decorate
The error:
Draper::UninferrableDecoratorError in Admin::DiagnosticsController#index
Could not infer a decorator for ActiveRecord::Base.
It may just be the nested namespace that's causing the issue. Can you reproduce with simple Ruby classes?
I've run into the same issue trying to use Draper with the audited gem. The audits can be accessed as, e.g. Audited::Audit.new
. I've tried a variety of syntax in a decorator for it, but get this same error (and Unable to autoload constant AuditDecorator
with some of the syntax I've tried).
Is there a recommended syntax for defining a Draper decorator for use with a namespaced class?