Ruby on rails 使用acts_as_votable时,如何获取所有喜欢社区的用户?

Ruby on rails 使用acts_as_votable时,如何获取所有喜欢社区的用户?,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我在社区\u controller.rb中有'like'动作 如果我想获取当前喜欢社区的所有用户,我如何在controller中编写? 我正在使用名为acts\u as\u votable的gem 应该是这样的吗 @community=community.find(参数[:id]) @users=User.likes@community communities\u controller.rb def like if current_user.voted_up_on? @community

我在社区\u controller.rb中有'like'动作 如果我想获取当前喜欢社区的所有用户,我如何在controller中编写? 我正在使用名为acts\u as\u votable的gem

应该是这样的吗

@community=community.find(参数[:id])
@users=User.likes@community

communities\u controller.rb

def like
    if current_user.voted_up_on? @community
        current_user.dislikes @community
        flash[:notice] = "Deleted from favorite"
    else
        current_user.likes @community
        flash[:notice] = "Added to favorite"
    end

    respond_to do |format|
        format.html { redirect_to @community }
    end
end

要获得所有喜欢社区的用户,您可以编写

@community.likes

查看以了解您执行的所有其他操作。

谢谢,但这将返回错误。它似乎无法吸引用户@community.likes.order(“上次在描述中签名”)。限制(3)。每个用户|