Pagination links with separator


#1

Hi,

I have @result_pages and @results obtained from paginate in an action. I
want to show the pages as
1 | 2 | 3 | 4 >
The fifth page will show:
< 5 | 6 | 7 | 8 >
and so on.
How exactly do I render the paginator to give this effect? I guess I
will have to use pagination_links_each. But being new to Rails, I need
help.

Thanks,
Yash


#2

On Apr 18, 2006, at 15:14, Yash wrote:

will have to use pagination_links_each. But being new to Rails, I need
I wrote this helper for an application where pagination and ordering
were done through Ajax:

Returns the links to pages for paginated listings.

def pagination_links_remote(options={})
paginator = options[:paginator]
actions = []
1.upto(paginator.page_count) do |n|
if paginator[n] == paginator.current_page
actions << n.to_s
else
options[:url][:page] = n
actions << link_to_remote(n.to_s, options)
end
end
“[ #{actions.join(’ | ')} ]”
end

It was invoked this way:

<% if @employee_pages.page_count > 1 %>

<%= pagination_links_remote( :paginator => @employee_pages, :update => 'listing', :url => { :action => 'listing', :order_by => @current_order_by, :direction => @current_direction, } ) %>

<% end %>

As you see some details come from the usage I wanted, but that’s the
idea.

– fxn