-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation failed: Visit must exist #276
Comments
Hey @jfrankov, you can add |
Thanks for the reply. I'll play with it some more. |
I just had this issue and modifying belongs_to :visit, optional: true
belongs_to :user, optional: true fixed it for me. Ruby 2.4.1, Rails 5.1.1 & ahoy_matey 1.6.0 |
@ankane I think it's caused because there's no visit at the time when |
Same thing happened with me. |
Same here, couldn't figure out what was causing this.. Eventually I went for calling the following method def ensure_visit
return if ahoy.visit
ahoy.track_visit
end |
Are you using visitable? You should be able to call However, there is a bug in Ahoy::Model#visitable that causes this for me:
The workaround is to call |
I have the same issue. IMO |
Ahoy 2.0 (just released) attempts to create a visit if one doesn't exist before creating an event, which should fix this. You can do this in Ahoy 1 with: class Ahoy::Store
def track_event(name, properties, options)
ahoy.track_visit unless visit
super
end
end |
I just installed ahoy on a rails 5 project, added this line to the create action of my controller:
and I get "Validation failed: Visit must exist". My visit.rb model already has this line in it:
...so that might not matter.
Any ideas?
The text was updated successfully, but these errors were encountered: