Reputation: 2223
im using kaminari. It's working with a chain and i have ActiveRecord::Relation object, but i cant figure out, howto avoid this error.
Code here, have trouble with stackoverflow redactor :/ http://pastie.org/1602799
Problem is when i hit tag, i got error
undefined method `current_page' for #<ActiveRecord::Relation:0x9ee7cb8>
I seen some solution, but they for will_paginate and seems deprecated, how can i do pagination for tag_cloud properly? Without pagination everything work perfectly.
I try both kaminari and will_paginate, both give me errors :(
Upvotes: 2
Views: 1185
Reputation: 891
For those of us that want to see the questions code from the pastie without having to tab back and forth. (made it really hard to see what the solution was on a small screen)
def index
@posts = Post.page(params[:page]).per(5)
tag_cloud
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
end
end
def tag
@posts = Post.tagged_with(params[:id])
@tags = Post.tag_counts_on(:tags)
render :action => 'index'
end
def tag_cloud
@tags ||= Post.tag_counts_on(:tags)
end
View
%h1 Listing posts
-tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class|
= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class
Upvotes: 2
Reputation: 5767
Does this have any effect?
def tag
@posts = Post.tagged_with(params[:id]).page(params[:page])
@tags = Post.tag_counts_on(:tags)
render :action => 'index'
end
Upvotes: 3