Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def show
- Bottle.increment_counter :views, @bottle
- end
- def show
- if !@bottle.ips.include?(request.remote_ip)
- Bottle.increment_counter :views, @bottle
- Ip.create(bottle_id: @bottle, ip: request.remote_ip )
- end
- end
- def show
- # see if they already have a cookie, if so
- # it will create a cookie with the Hit id you created
- if cookies.has_key?(:unique_hit_key)
- hit = Hit.find(cookies[:unique_hit_key])
- hit.count = hit.count.to_i+1
- hit.save
- else
- cookies[:unique_hit_key] = {
- :value => Hit.create(count: 1).id,
- :expires => 1.year.from_now,
- :domain => 'domain.com'
- }
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement