Skip to content

Commit

Permalink
Added Mongoid instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 2, 2023
1 parent 43c3fdd commit d18d8f4
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/ahoy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,29 @@ module Ahoy

def self.cookies=(value)
if value == false
# TODO add Mongoid instructions
raise <<~EOS
This feature requires a new index in Ahoy 5. Create a migration:
if defined?(Mongoid::Document) && defined?(Ahoy::Visit) && Ahoy::Visit < Mongoid::Document
raise <<~EOS
This feature requires a new index in Ahoy 5. Set:
add_index :ahoy_visits, [:visitor_token, :started_at]
class Ahoy::Visit
index({visitor_token: 1, started_at: 1})
end
Run it before upgrading, and set:
Create the index before upgrading, and set:
Ahoy.cookies = :none
EOS
Ahoy.cookies = :none
EOS
else
raise <<~EOS
This feature requires a new index in Ahoy 5. Create a migration with:
add_index :ahoy_visits, [:visitor_token, :started_at]
Run it before upgrading, and set:
Ahoy.cookies = :none
EOS
end
end
@@cookies = value
end
Expand Down

0 comments on commit d18d8f4

Please sign in to comment.