Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. def show
  2. Bottle.increment_counter :views, @bottle
  3. end
  4.  
  5. def show
  6. if !@bottle.ips.include?(request.remote_ip)
  7. Bottle.increment_counter :views, @bottle
  8. Ip.create(bottle_id: @bottle, ip: request.remote_ip )
  9. end
  10. end
  11.  
  12. def show
  13. # see if they already have a cookie, if so
  14. # it will create a cookie with the Hit id you created
  15. if cookies.has_key?(:unique_hit_key)
  16. hit = Hit.find(cookies[:unique_hit_key])
  17. hit.count = hit.count.to_i+1
  18. hit.save
  19. else
  20. cookies[:unique_hit_key] = {
  21. :value => Hit.create(count: 1).id,
  22. :expires => 1.year.from_now,
  23. :domain => 'domain.com'
  24. }
  25. end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement