我正在使用draper,我想在视图中使用其中的一个装饰器。
使用可以工作,但是装饰器在Ajax版本中不起作用--我得到了一个未定义的方法错误。
在CommentDecorator中:
delegate_all
def comment_author
"#{user.firstname} #{user.lastname}"
end考虑到:
comment.comment_author我使用公开,所以我不需要视图中的实例变量。
发布于 2015-06-13 20:44:40
您可以使用comment.decorate.comment_author
https://stackoverflow.com/questions/30823291
复制相似问题