Class: RatingsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RatingsController
- Defined in:
- app/controllers/ratings_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/ratings_controller.rb', line 5 def create @rating = ::ActsAsStarrable::Rating.new(:starrable_type => params[:stype], :starrable_id => params[:id], :rating => params[:value], :rater_type => params[:rtype], :rater_id => params[:rid]) if @rating.save render :json => @rating, :status => :created else render :json => @rating.errors, :status => :unprocessable_entity end end |
#destroy ⇒ Object
27 28 29 30 31 |
# File 'app/controllers/ratings_controller.rb', line 27 def destroy = ::ActsAsStarrable::Rating.find(params[:id]) .destroy render :nothing => true, :status => 204 end |
#update ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/ratings_controller.rb', line 18 def update = ::ActsAsStarrable::Rating.find(params[:id]) if .update_attributes(:rating => params[:value]) render :nothing => true, :status => 204 else render :nothing => true, :status => :unprocessable_entity end end |