我正在使用一个装饰器有些困难。我从未使用过装饰器,一直在尝试将其用于我的某个项目,用于拆分某些电子邮件。
但是,由于我以前从未使用过装饰器,即使是在我的装饰器上做一些非常简单的事情也很困难。我认为这与我的设置有关。我确实知道,除了我的小功能(即gemfile
之类)以外,所有内容都是最新和正确的。
我遇到的错误非常简单,如下所示:
无法推断出ActiveRecord::Base的装饰器。
现在我有一个几乎为空的控制器,但其中我保存了活动记录部分,如下所示。
class Admin::ReceivedEmailsController < Admin::ApplicationController
我的看法是,
_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
我觉得这应该是一个非常基础的东西,但我不确定它是什么。是否有人知道我缺少了什么?