Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.28 KB | None | 0 0
  1. def show
  2.     @post = Post.find(params[:id])
  3.     @author = Author.find(@post.author_id)
  4.     @votes = Vote.find_by(post_id: params[:id])
  5.     @score = 0
  6.     @votes.each do |vote|
  7.       if vote.vote_type == 0
  8.         @score += 1
  9.       else
  10.         @score -= 1
  11.       end
  12.     end
  13.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement