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.
30bc1830dbe1b5d773cbe4fcb1051ebe?d=identicon&s=25 Chris Hackel (chrish)
on 2006-04-06 19: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
49c38b11918618294f164df6cd9d84c1?d=identicon&s=25 Dan Perez (perezda)
on 2006-04-06 20:35
Chris Hackel 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.