سؤال

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

هل كانت مفيدة؟

المحلول

Try:

def increment(article)  
  if request.referer != request.original_url
    # increment code
  end
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top