Rendering partials with pagination

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

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs