impressionist icon indicating copy to clipboard operation
impressionist copied to clipboard

Model name is not detected properly

Open ElvinEfendi opened this issue 10 years ago • 1 comments

I have a model called Blog::Post and I'd like to count impressions for it. The controller is named according to the convention: Blog::PostsController. In this scenario impressionist will set impressionable_type to Post because of the following implementation:

def direct_create_statement(query_params={})
  query_params.reverse_merge!(
    :impressionable_type => controller_name.singularize.camelize,
    :impressionable_id=> params[:id]
    )
  associative_create_statement(query_params)
end

But it should be "Blog::Post". Therefore I'd suggest to use controller_path instead of controller_name to detect impressionable_type

It would even be better if impressionist method of controller accepts options to manually set model name because sometimes a model without namespace(Post) might be used in a controller with namespace(Admin::PostsController)

ElvinEfendi avatar Jul 26 '14 19:07 ElvinEfendi

I know this is years later - but in case anyone like me comes across this issue via google while trying to get namespaced controllers logged, this functionality was actually added in #71, but removed again in ce935aaa38c21aef13bbdb4efc34332fcfb5b4c0

martinbjeldbak avatar Apr 28 '18 09:04 martinbjeldbak