Will_paginate params

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

maybe this
<%= will_paginate @companies, :params => { ‘search_text’ => @search_text
} %>

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]
@[email protected]_sd_ui_hash[:number]
@[email protected]_sd_ui_hash[:service_desk_status_id]

@search_sd_ticket = ServiceDeskTicket.find_where(:all ) do |sd|
sd.number.downcase =~ “%”[email protected]_ticket_number.downcase+"%" if
!@sd_ticket_number.nil?
sd.service_desk_status_id== @sd_ticket_status_id
end

@[email protected]_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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs