lib/ahoy/model.rb in ahoy_matey-2.2.1 vs lib/ahoy/model.rb in ahoy_matey-3.0.0
- old
+ new
@@ -1,16 +1,14 @@
module Ahoy
module Model
def visitable(name = :visit, **options)
class_eval do
- safe_options = options.dup
- safe_options[:optional] = true if Rails::VERSION::MAJOR >= 5
- belongs_to(name, class_name: "Ahoy::Visit", **safe_options)
+ belongs_to(name, class_name: "Ahoy::Visit", optional: true, **options)
before_create :set_ahoy_visit
end
class_eval %{
def set_ahoy_visit
- self.#{name} ||= RequestStore.store[:ahoy].try(:visit_or_create)
+ self.#{name} ||= Thread.current[:ahoy].try(:visit_or_create)
end
}
end
end
end