lib/ahoy/model.rb in ahoy_matey-2.0.2 vs lib/ahoy/model.rb in ahoy_matey-2.1.0

- old
+ new

@@ -1,9 +1,11 @@ module Ahoy module Model def visitable(name = :visit, **options) class_eval do - belongs_to(name, optional: true, class_name: "Ahoy::Visit", **options) + safe_options = options.dup + safe_options[:optional] = true if Rails::VERSION::MAJOR >= 5 + belongs_to(name, class_name: "Ahoy::Visit", **safe_options) before_create :set_ahoy_visit end class_eval %{ def set_ahoy_visit self.#{name} ||= RequestStore.store[:ahoy].try(:visit_or_create)