pagination

Hi
   IN MY CONTROLLER

def search_sd_ticket
    @search_sd_ui_hash=params[:sd_ticket]
    puts @search_sd_ui_hash
    @sd_ticket_number=@search_sd_ui_hash[:number]
    puts @search_sd_ui_hash[:number]
    @sd_ticket_status_id=@search_sd_ui_hash[:service_desk_status_id]
   @sd_ticket_priority_id=@search_sd_ui_hash[:service_desk_priority_id]
  @sd_ticket_primary_assignee=@search_sd_ui_hash[:primary_assignee]
    @sd_ticket_start_date=@search_sd_ui_hash[:start_date]
    @sd_ticket_end_date=@search_sd_ui_hash[:end_date]
    @date_condition=nil

    #if @sd_ticket_start_date=="" or @sd_ticket_end_date==""
     # flash[:notice] = "Start date and end date are needed "
      # render :action => 'search_sd_ticket_ui'
    #end

          #@search_sd_ticket_result=ServiceDeskTicket.find(:all,
:conditions => "created_on > @sd_ticket_start_date AND created_on <
@sd_ticket_end_date")

          # step 1: set the variables you'll need
            page = (params[:page] ||= 1).to_i
            items_per_page = 20
            offset = (page - 1) * items_per_page
          @search_sd_ticket_result = ServiceDeskTicket.find_where(:all )
do |sd|
                                     sd.number.downcase =~
"%"+@sd_ticket_number.downcase+"%"
                                     sd.service_desk_status_id==
@sd_ticket_status_id
                                     sd.service_desk_priority_id==
@sd_ticket_priority_id
                                     sd.primary_assignee==
@sd_ticket_primary_assignee
                                     sd.created_on <=>
(@sd_ticket_start_date..@sd_ticket_end_date) if
!@sd_ticket_start_date.empty? and !@sd_ticket_end_date.empty?
                                 end

@item_pages = Paginator.new(self, @search_sd_ticket_result.length,
items_per_page, page)
@search_sd_ticket_result = @search_sd_ticket_result[offset..(offset +
items_per_page - 1)]

end

AND MY VIEW

<%= link_to('previous',
:page => @item_pages.current.previous) if @item_pages.current.previous
%>

<% puts @search_sd_ui_hash[:number]%>
<%= link_to('next',
:page => @item_pages.current.next,:sd_ticket=>@search_sd_ui_hash) if
@item_pages.current.next %>

FIRST PAGE OK .BUT WHEN I CLICK NEXT ERROR

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.downcase

WHAT MAY BE THE REASON
Sijo