Upgrading Ahoy Analytics - Routing Error - No Route
Analytics is a very useful tool, especially when it is available to you at demand. Ahoy is simply the only library that comes to my mind when Analytics and Rails both show up in the same sentence. Today I upgraded an old project of mine to Ahoy 3.2 (from 1.6) and I noticed a hiccup:
ActionController::RoutingError (No route matches [POST] "/ahoy/events")
If you were to follow the upgrade guide closely you will not encounter this. Ahoy 2 Upgrade Guide just states the config option Ahoy.api = true
which I thought was for Rails API stuff.
Then I checked the Ahoy source code and found its route definition getting activated only if this config is true.
Solution
The Ahoy routes get activated only when Ahoy.api
is true. In config/initializers/ahoy.rb
make sure to have
Ahoy.api = true
Happy upgrading!
About the Author
Ziyan Junaideen -
Ziyan is an expert Ruby on Rails web developer with 8 years of experience specializing in SaaS applications. He spends his free time he writes blogs, drawing on his iPad, shoots photos.