I want to be able to vote on my links without having to login through something like devise or other authentication system. I have devised installed on my application and it's up and running and works fine. But I don't want the user to have to be logged in to vote. I was thinking doing it through the IP Address and would be thankful if someone can help me through this process.
I want to clarify that I can vote without problem when I am logged in.
This is how my links_controller#upvote looks like:
def upvote
@link = Link.find(find_link)
respond_to do |format|
unless current_user.voted_for? @link
format.html { redirect_to :back }
format.json { head :no_content }
format.js { render :layout => false }
@link.cached_votes_total = @link.cached_votes_total + 1
@link.save
@link.upvote_by current_user
else
flash[:danger] = 'You allready voted this entry'
format.html { redirect_to :back }
format.json { head :no_content }
format.js
end
end
end
link.rb
acts_as_votable
user.rb (using devise)
acts_as_voter