Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draper::UninferrableDecoratorError (Could not infer a decorator for Document.) #891

Open
denmarkmeralpis opened this issue Oct 3, 2020 · 3 comments

Comments

@denmarkmeralpis
Copy link

denmarkmeralpis commented Oct 3, 2020

How can I infer a namespaced decorator? I got an error(which is expected) everytime I decorate Document model.

2.5.3 :010 > Document.first.decorate.created_at

Draper::UninferrableDecoratorError (Could not infer a decorator for Document.)
# app/decorators/example_namespace/document_decorator.rb
module ExampleNamespace
   class DocumentDecorator < ::Draper::Decorator
      delegate_all

      def created_at
         object.strftime('%D %r')
      end
   end
end

# app/models/document.rb
class Document < ApplicationRecord
...
end
@pduersteler
Copy link

pduersteler commented Dec 4, 2020

Did you had a look at #545 ? Just came across this as well.

Or if it helps, you could specify it in your controller with

decorates_association :document with: ExampleNamespace::DocumentDecorator

@pedrohgrandin
Copy link

If you use Spring, try:

spring stop

and restart your server/console

@n-rodriguez
Copy link
Contributor

See: #899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants