当我想从另一个控制器调用它时,如何调用decorate方法?

时间:2015-12-07 10:03:00

标签: ruby-on-rails draper

在用户的主页中,我想要显示用户的phrases

class StaticPagesController < ApplicationController
  def home
    if user_signed_in?
      @phrases = current_user.phrases.decorate
    end
  end
end

但是Could not infer a decorator失败了。我理解错误的发生是因为只有在适当的控制器中我才能使用decorate方法。 我读过this post,但我可能会误解它。

因此,如果我想在这种情况下使用decorate方法,有什么好办法可以解决它?

0 个答案:

没有答案