Forum: Ruby on Rails Rendering partials with pagination

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris H. (Guest)
on 2006-04-06 21:53
I currently have a call to this action, which I'd like to paginate:

  def get_words
      @catid = params[:category]
      @words = Category.find(@catid).words
      render :partial => "word_display", :collection => @words
  end

As you can see, a word_display partial is rendered for each word.

If I add the pagination call (getting the links object), how can I then
get this (the @word_pages) included on the rendered page?

@word_pages, @words = paginate( ... )

Thank you so much!
Chris
Dan P. (Guest)
on 2006-04-06 22:35
Chris H. wrote:
> I currently have a call to this action, which I'd like to paginate:
>
>   def get_words
>       @catid = params[:category]
>       @words = Category.find(@catid).words
>       render :partial => "word_display", :collection => @words
>   end
>
> As you can see, a word_display partial is rendered for each word.
>
> If I add the pagination call (getting the links object), how can I then
> get this (the @word_pages) included on the rendered page?
>
> @word_pages, @words = paginate( ... )
>
> Thank you so much!
> Chris

Hey Chris,

check out the wiki:
http://wiki.rubyonrails.com/rails/pages/PaginationHelper

then try something like this in your controller:
@word_pages, @words = paginate( ... )

then try something like this in your view:
<%= render( :partial => "word_display", :collection => @words) %>
<%= pagination_links(@word_pages) %>

Hope that helps,
Dan
This topic is locked and can not be replied to.