charlotte-ruby / impressionist

Rails Plugin that tracks impressions and page views
MIT License
1.54k stars 311 forks source link

Using slug, but not friendly_id; impressionable_id registering zero #215

Closed dvodvo closed 7 years ago

dvodvo commented 8 years ago

Using the standard rails find_page syntax def find_page @static = Static.find_by_slug!(params[:id]) end I have attempted in the controller to invoke the id of the object: @staticimpression = Static.find(@static.id) impressionist(@staticimpression)

However this still leads to 0 being registered in the Impression table for the class id. What is the best way to proceed, while wondering whether changing the migration for impressionable_id to string and adding an index would make sense (given slug is unique)...

jaykilleen commented 7 years ago

I'm also trying to resolve this issue. Will report back if I find a workaround.

dsvoba commented 7 years ago

There is a workaround. You can manually log impression in your controller action. First remove impressionist from controller (to avoid double logging) and add impressionist(@object) to the action.

jgrau commented 7 years ago

The solution provided by @dsvoba is the official one. Does that not work for you? I'll close this but please reopen if it doesn't work.