Hi I have the controller code as below # step 1: set the variables you''ll need page = (params[:page] ||= 1).to_i items_per_page = 20 offset = (page - 1) * items_per_page # step 2: instead of performing the full find, just find the record count @search_sd_ticket_count_result ServiceDeskTicket.find_where(:all,:select=>''count(*) as count1'' ) do |sd| end record_count=@search_sd_ticket_count_result[0].count1.to_i # step 3: create a Paginator, the second variable has to be the number of ALL items on all pages @search_sd_ticket_result_pages = Paginator.new(self, record_count, items_per_page, page) # step 4: only find the requested subset of @search_sd_ticket_result @search_sd_ticket_result ServiceDeskTicket.find_where(:all,:offset=>offset,:limit=>items_per_page ) do |sd| end How can I move this code to model so that to call it other places also Sijo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---