class VotesController < ApplicationController
def create
@vote = Vote.find_or_initialize_by_submitted_by_ip(request.remote_ip)
@vote.update_attributes(params[:vote]) if !@vote.has_user?(session[:user_id])
render json: @vote
end
end
class Vote < ActiveRecord::Base
def has_user?(uid)
self.user_id.eql?(uid)
end
end
Last active
December 14, 2015 19:59
-
-
Save leepfrog/5140428 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment