Master ruby with us

AJAX pagination in Ruby on Rails

Posted by firstruby on November 29, 2009

For users list, I wanted to have AJAX pagination.

For Ruby on Rails version 2.3.x,

1) Install will_paginate gem “config.gem “will_paginate”” or include will_paginate plugin in vendor/plugins.

2) Create helper file at /app/helpers/remote_link_renderer.rb with following content,
Here I’m attaching remote_link_renderer.rb.pdf file , copy contents from remote_link_renderer.rb.pdf and create file remote_link_renderer.rb

3) In controller action, write as following,

if request.xhr?
render :update do |page|
page.replace_html "users_list", :partial => "users", : object => @users

4) On “_users_list.html.erb” view page, write as,

= will_paginate @users, :renderer => 'RemoteLinkRenderer'


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: