我可以显示用户喜欢的投票,但我不知道如何显示喜欢记录的实际记录。检索用户投票记录的最简单方法是什么?
控制器.rb
def show
@user = User.find(params[:id])
@liked = @user.votes
end
显示.html.haml
= @liked.to_json
结果:
[{"id":5,"votable_id":8,"votable_type":"Post","voter_id":2,"voter_type":"User","vote_flag":true,"vote_scope":null,"vote_weight":1,"created_at":"2016-02-01T00:33:15.968Z","updated_at":"2016-02-01T00:33:15.968Z"}]
我该如何打开它,以便我可以显示帖子记录中的标题、描述等...?