我在 communities_controller.rb 中有'喜欢'操作 如果我想获取当前喜欢社区的所有用户该怎么办?如何在控制器中编写? 我正在使用名为 acts_as_votable
的gem应该是这样的吗?
@community = Community.find(params [:id])
@users = User.likes @community
communities_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