I've a simple rating system setup in a blog model. I use a custom method to increase rating, which is integer in blog db.
def increase
@post = Post.find(params[:id]).increment!(:rating)
if logged_in?
current_user.increment!(:votes)
end
flash[:notice] = "Thanks for rating"
redirect_to posts_url
end
Right now, I can vote as many times as I want, which is of course a recipe for disaster. Users can vote multiple times and drive the count way way up.
How do I make it so that the vote submit button go away after submitting it once. I thought of making a separate model for rating and use a custom token, but seems needlessly complicated for a simple app.
Any help?
Senthil