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