app/models/user.rb
# Returns user vote on given resource. If user hasn't voted then nil is
# returned.
Returns user vote on given resource. If user hasn't voted then nil is
returned.
Returns user vote on given resource . If user hasn ' t voted then nil is returned .
def find_vote_on(resource)
    if resource.class == Post
      PostVote.find_by(user_id: id, post_id: resource.id)
    elsif resource.class == Topic
      TopicVote.find_by(user_id: id, topic_id: resource.id)
    end
  end
def find_vote_on ( resource ) if resource . class == Post PostVote . find_by ( user_id : id , post_id : resource . id ) elsif resource . class == Topic TopicVote . find_by ( user_id : id , topic_id : resource . id ) end end
Returns user vote on given resource.
Returns user vote on given resource .
resource
<not_specific>