I'm trying to use Redis to keep track of page views so I can figure out which pages get the most views from incoming traffic (rather than from browsing within the site). However, right now when I check the quote ID in Redis, the value being returned is nil. I've added both to routes.rb. Thanks!
Here's the Javascript I'm using:
function viewCount(quote_id) { $.ajax({ type:"PUT", url:"/quotes/" + quote_id +"/viewed", contentType:"json" }); } function quoteReferrer(quote_id){ if ((document.referrer != null) && (location.hostname !=(document.referrer.split('/')[2]))) { $.ajax({ type:"PUT", url:"/quotes/" + quote_id +"/referred", contentType:"json" }) } }
The Ruby controller code:
def viewed REDIS.incr("quote_id_#{params[:id]}_viewed_count") puts params[:id] respond_to do |format| format.json { head :ok } end end def referred REDIS.incr("quote_id_#{params[:id]}_referred") puts params[:id] respond_to do |format| format.json { head :ok } end end