# Will\_paginate params

**URL:** <https://www.ruby-forum.com/t/will-paginate-params/138099>\
**Category:** Rails\
**Created:** [May 20, 2008, 8:07am UTC](https://www.ruby-forum.com/t/will-paginate-params/138099 "2008-05-20T08:07:54Z")\
**Posts on this page:** 3\
**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 20, 2008, 8:07am UTC](https://www.ruby-forum.com/t/will-paginate-params/138099/1 "2008-05-20T08:07:54Z")

</div>

Hi  
I hav a search UI.And I use will\_paginate to paginate result.My action  
is  
def search\_sd\_ticket  
#@search\_sd\_ui\_hash=params[:sd\_ticket]  
@search\_sd\_ticket\_result=ServiceDeskTicket.record\_paginate\_sd(params[:sd\_ticket],params[:page])

end

and in ServiceDeskTicket model

def self.record\_paginate\_sd(search\_sd\_ui\_hash,page)  
def self.record\_paginate\_sd(search\_sd\_ui\_hash,page)  
paginate(:page =\> page, :conditions =\> [“number LIKE ?”,  
“%#{sd\_ticket\_number}%”],  
:per\_page =\> 10,  
:order =\> “number”)

end

My problem is the first page comes but when i click on the next page the  
following error happens  
You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occurred while evaluating nil.[]

The second time params[:sd\_ticket] has no value…ow can I solve  
this?Please help

Sijo

---

<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 20, 2008, 8:17am UTC](https://www.ruby-forum.com/t/will-paginate-params/138099/2 "2008-05-20T08:17:21Z")

</div>

maybe this  
\<%= will\_paginate @companies, :params =\> { ‘search\_text’ =\> @search\_text  
} %\>

---

<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 20, 2008, 9:27am UTC](https://www.ruby-forum.com/t/will-paginate-params/138099/3 "2008-05-20T09:27:44Z")

</div>

Hi  
Thanks a lot for ur reply.It worked.So my complete current code as  
below.this is working  
def search\_sd\_ticket  
@search\_sd\_ui\_hash=params[:sd\_ticket]  
@sd\_ticket\_number=@search\_sd\_ui\_hash[:number]  
@sd\_ticket\_status\_id=@search\_sd\_ui\_hash[:service\_desk\_status\_id]

@search\_sd\_ticket = ServiceDeskTicket.find\_where(:all ) do |sd|  
sd.number.downcase =~ “%”+@sd\_ticket\_number.downcase+"%" if  
!@sd\_ticket\_number.nil?  
sd.service\_desk\_status\_id== @sd\_ticket\_status\_id  
end

@search\_sd\_ticket\_result=@search\_sd\_ticket.paginate :per\_page=\>10,  
:page=\>params[:page],:sd\_ticket=\>params[:sd\_ticket]

end

So the above code is working…Now chow can i move this to model.I tried  
like in controller  
@search\_sd\_ticket\_result=ServiceDeskTicket.record\_paginate\_sd(params[:sd\_ticket],  
params[:page]) And in model self.record\_paginate\_sd method pasted the  
above…But some where mistake and i can’t figure out.No error.But no  
result…Could you please tell me how to move the above working code to  
model?

Thanks in advance  
Sijo
