docbrown/app/controllers/rating_votes_controller.rb
Ben Halpern 0817e2ac9e
Create implicit experience level rating vote upon creating of readinglist reaction (#6522) [deploy]
* Do not render or link to empty rss feeds

* s

* Move calculation to worker

* remove xit test

* Also allow implicit rating votes in comments

* Fix alignment issue

* Remove comment logic
2020-03-10 10:59:49 -04:00

23 lines
748 B
Ruby

class RatingVotesController < ApplicationController
after_action :verify_authorized
def create
authorize RatingVote
rating_vote = RatingVote.where(user_id: current_user.id, article_id: rating_vote_params[:article_id]).first || RatingVote.new
rating_vote.user_id = current_user.id
rating_vote.article_id = rating_vote_params[:article_id]
rating_vote.rating = rating_vote_params[:rating].to_f
rating_vote.group = rating_vote_params[:group]
if rating_vote.save
redirect_back(fallback_location: "/mod")
else
render json: { result: "Not Upserted Successfully" }
end
end
private
def rating_vote_params
params.require(:rating_vote).permit(policy(RatingVote).permitted_attributes)
end
end