# Will\_paginate and RJS

**URL:** <https://www.ruby-forum.com/t/will-paginate-and-rjs/137359>\
**Category:** Rails\
**Created:** [May 12, 2008, 11:36am UTC](https://www.ruby-forum.com/t/will-paginate-and-rjs/137359 "2008-05-12T11:36:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [May 12, 2008, 11:36am UTC](https://www.ruby-forum.com/t/will-paginate-and-rjs/137359/1 "2008-05-12T11:36:37Z")

</div>

Hi  
What my problem is I have a controller action and this action has  
content for the various tabs of the view .Some  
attchments,activities,resolutions etc…And this file is called only once  
and all the other is planning in the ajax way .The controller code is  
def show\_details()  
@sd\_ticket=ServiceDeskTicket.find(params[:id])  
@sd\_attachments=service\_desk\_ticket.service\_desk\_attachments.display\_sd\_attachments(params[:page])  
@sd\_activities=ServiceDeskActivity.find\_all\_by\_service\_desk\_ticket\_id(@sd\_ticket)

# Here also i have introduce pagination as above this is the second tab

in the view  
--------code for other tabs  
end

And for the first in the ServiceeskAttachment.rb model file i wrote  
def self.display\_sd\_attachments(page)  
paginate :per\_page =\> 5, :page =\> page  
end  
So the pagination is working .The view partial has \<%= will\_paginate  
@sd\_attachments%\>

But from now onwards what my yet to be solved comes…What i need is  
clicking on page 2,3 etc i have to invoke an ajax call and only tat  
tab get updated to the required page.And I could implement it with  
the rails pagination as below  
ï»¿\<%= link\_to\_remote(‘Previous’, {:url =\> {:action =\>  
:show\_attachment\_page, :ci =\> @ci.id, :content =\> ‘show’, :page =\>  
@hardware\_ci\_attachments\_pages.current.previous}}) if  
@hardware\_ci\_attachments\_pages.current.previous %\> same for next  
page…But I want to avoid this since this pagination is obsolete.

So as above how can i specify an action with will\_paginate (which is  
another action handling the ajax ) so what i am trying to do is inside  
that action i can do the pagination and use RJS to replace this partial  
file…Actually I understood responds\_to now…So please help me…And i am  
not an expert with ajax

Sijo
