fix hakiri issue and added authorization
This commit is contained in:
parent
c07fd304c0
commit
360a764cb4
2 changed files with 10 additions and 1 deletions
|
|
@ -1,7 +1,14 @@
|
|||
class RaterController < ApplicationController
|
||||
load_and_authorize_resource :rate
|
||||
|
||||
def create
|
||||
if user_signed_in?
|
||||
obj = params[:klass].classify.constantize.find(params[:id])
|
||||
votable_type = ''
|
||||
VotableField::VALID_VOTABLE_TYPES.each do |valid_votable_type|
|
||||
votable_type = valid_votable_type
|
||||
break if params[:klass] == votable_type
|
||||
end
|
||||
obj = votable_type.classify.constantize.find(params[:id])
|
||||
obj.rate params[:score].to_f, current_user, params[:dimension]
|
||||
|
||||
render json: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue