There is any way to use impressionist gem with will paginate? I try to use impressionist to a will_paginate
collection like this:
posts = Post.all.paginate(:page => params[:page])
impressionist(posts)
But It raises this error:
WillPaginate::Collection is not impressionable!
There is any way to use impressionist method directly on view?
The collection generated by will_paginate
is not impressionable means exactly you are reading, it's class doesn't have any calls to is_impressionable
, as your model should have. If it doesn't, add it like this:
class Post < ActiveRecord::Base
# ...other stuff
is_impressionable
end
Then, if you can't call it in the collection, why not call it in each record instead? Try like this:
posts = Post.all.paginate(:page => params[:page])
posts.each{|post| impressionist(post) }
Maybe it's not the most elegant solution, but it will get the work done. As of doing this in your view, I wouldn't advise it. Impressionist creates a database record, which would slow your view rendering. It will be better to do it in the model or controller layers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With