Im using this paginate function to paginate complex sql queries
BigBold - Informasi Tentang Bisnis dan Marketing, all seems to work fine
but theres one thing, when i hit the next link it show nothing, i mean
it only shows the first page, here is the code im using:
#application.rb-----------------
def paginate_collection(collection, options = {})
default_options = {:per_page => 10, :page => 1}
options = default_options.merge options
pages = Paginator.new self, collection.size, options[:per_page],
options[:page]
first = pages.current.offset
last = [first + options[:per_page], collection.size].min
slice = collection[first…last]
return [pages, slice]
end
#Controller---------------------
@paginas, @entradas = paginate_collection Entrada.find(:all,
:conditions => [‘month(creado_en) = ?’, params[:mes]],
:order => ‘id desc’), :page => @params[:page]
#View---------------------------
<%= link_to ‘Previous page’, { :page => @paginas.current.previous } if
@paginas.current.previous %>
<%= link_to ‘Next page’, { :page => @paginas.current.next } if
@paginas.current.next %>
I think its something whit the pagination links but i cant make it to
work, so any help rubists