Im using this paginate function to paginate complex sql queries
http://www.bigbold.com/snippets/posts/show/389, 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 ;)
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---