Old rails has a buitl in pagination option. For example is you have to paginate @user, which is a model object for the table user

def user_list
@user_pages,@users=paginate(:users,:order=>’name’)
end

But in new version of rails, they removed the pagination option. So you need to install a plugin , which name is will_paginate

You can install this plugin using gem

gem install will_paginate

After the installation you have to add require “will_paginate” in config/environment.rb (at bottom)

You have to restart your ruby server after that.

In the controller area use:

def index
  @poems = Poem.paginate :page => params[:page], :o rder => 'created_at DESC'
end

and in the template page use

<%= will_paginate @poems, :container => false %>

Tags: , , ,

· · · ◊ ◊ ◊ · · ·

وظائف 2011 تحويل العملات برامج برنامج تسريع التحميل برنامج الفلاش برنامج محول الصوتيات عربي hotel 2011 زيادة رواتب العساكر 1431