Question

My problem is to get referer after page refresh. I need to find out if the user does not reloaded page. In my articles_controller i check before article.views_count increment

def increment(article)  
  if request.referer != article_url(article)
    # increment code
  end
end

but request.referer returns url, that was before reload and after each page refresh method increment is running

Was it helpful?

Solution

Try:

def increment(article)  
  if request.referer != request.original_url
    # increment code
  end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top