Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow controllers to be tracked without having a model #54

Closed
newmana opened this Issue Oct 19, 2012 · 2 comments

Comments

Projects
None yet
3 participants

newmana commented Oct 19, 2012

At the moment the code takes the name of the Controller and assumes that there's a Model of the same name.

Line 81 of impressionist_controller.rb:
:impressionable_type => controller_name.singularize.camelize,

Line 11 of /lib/impressionist/models/active_record/impression.rb:
impressionable_class = self.impressionable_type.constantize

This will fail if there's a "PostController" but no "Posts" model.

Steps to reproduce:
1/ Delete "Posts" model.
2/ rake spec

Expected behavior:
That the controller saves itself as the type ie. impressionable_type is "self.class.to_s" and impression.rb doesn't try and call constantize a model that doesn't exist.

I have an app we have written with a survey controller (that dynamically renders pages / sections / forms) and ran into this issue (since one of my controllers isn't tied to a model). Anyone ever looked at trying to work around this issue? I'm willing to checkout and try a work around since this is easier than writing my own analytics engine for our app.

Member

acnalesso commented Jul 6, 2013

Fixed on #92.
It writes to log file if it can not find a existing model, Therefore it does not update_counters.

@acnalesso acnalesso closed this Jul 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment