Added controller extension

Andrew Kane committed Feb 26, 2014
commit 00755c16a32381cfe81493abe46de8172a8932ad
Showing 3 changed files with 12 additions and 1 deletions
README.md +0 -1
@@ @@ -5,7 +5,6 @@ Simple, powerful visit tracking for Rails.
## TODO
- better readme
- - controller integration
- model integration
- update visit when user logs in
- better browser / os detection
ahoy/controller_extensions.rb b/lib/ahoy/controller_extensions.rb +9 -0
@@ @@ -0,0 +1,9 @@
+ module Ahoy
+ module ControllerExtensions
+
+ def ahoy_visit
+ @ahoy_visit ||= Ahoy::Visit.where(visit_token: cookies[:ahoy_visit]).first if cookies[:ahoy_visit]
+ end
+
+ end
+ end
ahoy_matey.rb b/lib/ahoy_matey.rb +3 -0
@@ @@ -1,4 +1,5 @@
require "ahoy/version"
+ require "ahoy/controller_extensions"
require "addressable/uri"
require "browser"
require "geocoder"
@@ @@ -8,3 +9,5 @@ module Ahoy
isolate_namespace Ahoy
end
end
+
+ ActionController::Base.send :include, Ahoy::ControllerExtensions