app/controllers/swimming_pool_reviews_controller.rb
# Casts a vote (either up or down) for the specified review id.
#
# TODO FUTUREDEV: add support for xhr request in this action
#
# === Params:
# - :id   => the SwimmingPoolReview.id
# - :vote => any value cast to a positive integer equals a single upvote; anything
#            else (even nil) is a downvote.
Casts a vote (either up or down) for the specified review id.
TODO FUTUREDEV: add support for xhr request in this action

:id   => the SwimmingPoolReview.id
:vote => any value cast to a positive integer equals a single upvote; anything
else (even nil) is a downvote.
Casts a vote ( either up or down ) for the specified review id . TODO FUTUREDEV : add support for xhr request in this action : id = > the SwimmingPoolReview . id : vote = > any value cast to a positive integer equals a single upvote ; anything else ( even nil ) is a downvote .
def vote
    @review = SwimmingPoolReview.find_by_id(params[:id])
    if @review
      (params[:vote].to_i > 0) ? @review.liked_by(current_user) : @review.downvote_from(current_user)
      flash[:info] = I18n.t('swimming_pool_review.thanks_for_the_vote')
    else
      flash[:error] = I18n.t(:invalid_action_request)
    end
    redirect_to(root_path) and return
  end
def vote @review = SwimmingPoolReview . find_by_id ( params [ :id ] ) if @review ( params [ :vote ] . to_i > 0 ) ? @review . liked_by ( current_user ) : @review . downvote_from ( current_user ) flash [ :info ] = I18n . t ( 'swimming_pool_review.thanks_for_the_vote' ) else flash [ :error ] = I18n . t ( :invalid_action_request ) end redirect_to ( root_path ) and return end
Casts a vote (either up or down) for the specified review id.
Casts a vote ( either up or down ) for the specified review id .