Using Decorator, (rails) Failed to display decorator for ActiveRecord :: Base

I'm having trouble using the decorator. I had never used it before, and I tried to use it in relation to what I was doing to break emails.

However, since I had never used it before, I had problems even with very simple things with my decorator, and I think some form of installation is associated with it. I know that everything that is beyond my little trait (aka gemfile, etc.) is all up to date with the latest developments.

The error I get is simple,

Failed to display decorator for ActiveRecord :: Base.

Now I have a controller that is almost empty, but inside it I have the active part of the record saved like this.

class Admin::ReceivedEmailsController < Admin::ApplicationController

From my point of view,

_receive_email.html.haml

, , , :

  %td= received_email.decorate

class Admin::ReceivedEmailsDecorator < Admin::ApplicationDecorator

def received_email
 if can? :update, @customer
   received_email.content
 else
   "You need to have the correct admin access to view the email"
 end
end

, , , , . - , ?

+4
1

, . , . - .

+2

Source: https://habr.com/ru/post/1617111/


All Articles