Module: QuestionsHelper

Defined in:
app/helpers/questions_helper.rb

Overview

Provides helper methods for use by views under QuestionsController.

Instance Method Summary collapse

Instance Method Details

#my_vote(question) ⇒ Vote?

Returns the current user’s vote for the specified post, or nil if no user is signed in.

Parameters:

  • question (Post)

    The post for which to find a vote.

Returns:



7
8
9
# File 'app/helpers/questions_helper.rb', line 7

def my_vote(question)
  user_signed_in? ? question.votes.where(user: current_user).first : nil
end