Made ahoy engine optional (#178)

Gabriel Klein committed Jun 21, 2016
commit 19db586f2f7d498e3f1cd0f1e9b826406a9ab5b6
Showing 6 changed files with 15 additions and 4 deletions
README.md +8 -0
@@ @@ -436,6 +436,14 @@ Debug endpoint requests in Ruby
Ahoy.quiet = false
```
+ ### Rails engine
+
+ You can disable the engine
+
+ ```ruby
+ Ahoy.mount = false
+ ```
+
## Explore the Data
How you explore the data depends on the data store used.
config/routes.rb +1 -1
@@ @@ -1,5 +1,5 @@
Rails.application.routes.draw do
- mount Ahoy::Engine => "/ahoy"
+ mount Ahoy::Engine => "/ahoy" if Ahoy.mount
end
Ahoy::Engine.routes.draw do
ahoy.rb b/lib/ahoy.rb +3 -0
@@ @@ -67,6 +67,9 @@ module Ahoy
mattr_accessor :max_events_per_request
self.max_events_per_request = 10
+ mattr_accessor :mount
+ self.mount = true
+
mattr_accessor :throttle
self.throttle = true
ahoy/stores/active_record_store.rb b/lib/ahoy/stores/active_record_store.rb +1 -1
@@ @@ -2,7 +2,7 @@ module Ahoy
module Stores
class ActiveRecordStore < BaseStore
def track_visit(options, &block)
- visit =
+ @visit =
visit_model.new do |v|
v.id = ahoy.visit_id
v.visitor_id = ahoy.visitor_id
ahoy/stores/active_record_token_store.rb b/lib/ahoy/stores/active_record_token_store.rb +1 -1
@@ @@ -2,7 +2,7 @@ module Ahoy
module Stores
class ActiveRecordTokenStore < BaseStore
def track_visit(options, &block)
- visit =
+ @visit =
visit_model.new do |v|
v.visit_token = ahoy.visit_token
v.visitor_token = ahoy.visitor_token
ahoy/stores/mongoid_store.rb b/lib/ahoy/stores/mongoid_store.rb +1 -1
@@ @@ -2,7 +2,7 @@ module Ahoy
module Stores
class MongoidStore < BaseStore
def track_visit(options, &block)
- visit =
+ @visit =
visit_model.new do |v|
v.id = binary(ahoy.visit_id)
v.visitor_id = binary(ahoy.visitor_id)