2016-09-22 20:06:46 -04:00
|
|
|
class RaterController < ApplicationController
|
2017-04-29 19:35:30 +00:00
|
|
|
load_and_authorize_resource :rate
|
|
|
|
|
|
2016-09-22 20:06:46 -04:00
|
|
|
def create
|
|
|
|
|
if user_signed_in?
|
2017-04-29 19:35:30 +00:00
|
|
|
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])
|
2016-09-22 20:06:46 -04:00
|
|
|
obj.rate params[:score].to_f, current_user, params[:dimension]
|
|
|
|
|
|
|
|
|
|
render json: true
|
|
|
|
|
else
|
|
|
|
|
render json: false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|