pagination_mainRuby on Rails pagination functionalities done by installing the simple will_paginate plugin. This can be installed by using the following  command executed on your ruby for Windows,

Once installed, you need to include the plugin library as

c:\wamp\Ruby>gem install will_paginate

require ‘will_paginate’

in the config/environment.rb bottom after the  below code in the  .rb file, do |config|

Live pagination in code:

Add the below code in your model to access by all the controller methods,

def display_data
if (page!=”)
 paginate(:all,:page => page, :conditions => [“user_id = ?”, id], :per_page =>10)
 paginate(:all,:page => 1, :conditions => [“user_id = ?”, id], :per_page =>10)

call the below function in your controller to invoke the paginate from the disaply_data as follows,

  @display_data = MessageHistory.more_update(params[:date],params[:page],session[:user_id])

Now here we need to show the pagination in the User view, for that we need to add the below code to invoke the pagination from the controller.

 <%= will_paginate @display_data %>

 Thats all  We have Compeleted the pagination. Once the above run sucessfully you will get the pagination like in the below format on your web page.

For the CSS updates goto this links and copy the CSS  and place it in your project folder (public/stylesheet)


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: