Skip to content

Instantly share code, notes, and snippets.

@marcamillion
Created May 7, 2011 22:26
Show Gist options
  • Save marcamillion/960909 to your computer and use it in GitHub Desktop.
Save marcamillion/960909 to your computer and use it in GitHub Desktop.
class UploadsController < ApplicationController
filter_resource_access
def vote_up
begin
current_user.vote_exclusively_for(@upload = Upload.find(params[:id]))
render :nothing => true, :status => 200
rescue ActiveRecord::RecordInvalid
render :nothing => true, :status => 404
end
end
def vote_down
begin
current_user.vote_exclusively_against(@upload = Upload.find(params[:id]))
render :nothing => true, :status => 200
rescue ActiveRecord::RecordInvalid
render :nothing => true, :status => 404
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment