Params object nil in controller action

Hi All

I am trying to implement a Back to Search Results functionality, by
storing
the user’s search criteria (params) in session and then reusing those
params instead of request params when user clicks on “Back to Search
Results
link”. here is my code


def search
if session[:incidentSearch].nil? or session[:incidentSearch].empty?

if no search criteria found in session

  logger.debug("if params.nil?=#{params.nil?}")
  logger.debug("NOT FOUND :incidentSearch")
  if (params[:routeNum].nil? or params[:routeNum].empty?) and
      (params[:incidentId].nil? or params[:incidentId].empty?) and
      (params[:startDateTime].nil? or params[:startDateTime].empty?) 

and

      (params[:endDateTime].nil? or params[:endDateTime].empty?)
    flash[:warning] = "Don't try stupid things....Enter some search

criteria."
redirect_to :back and return
elsif ((!params[:routeNum].empty? or !params[:incidentId].empty?)
and
(!params[:startDateTime].empty? and !params[:endDateTime].empty?) or
(!params[:routeNum].empty? and !params[:incidentId].empty?))
flash[:warning] = “Specify only one search criteria Reference#
or
Route or Date (Start and End both)”
redirect_to :back and return
end

elsif !session[:incidentSearch].nil? and

!session[:incidentSearch].empty? # if search criteria found in session
puts “elsif params.nil?=#{params.nil?}”
logger.debug(“elsif params.nil?=#{params.nil?}”)
logger.debug(“session[:incidentSearch] found …”)
params = session[:incidentSearch]
end

logger.debug("final params.nil?=#{params.nil?}") # *print true*
condition = nil
if params[:routeNum] and !params[:routeNum].empty? # *<=== params is 

nil
by now** *
condition = ["(route_num = ?)", params[:routeNum].strip]
end
#proceed with find operation in model and render results


here is my logger output when I search for the first time

if params.nil?=false
NOT FOUND :incidentSearch
final params.nil?=true


The funny thing is for first search the control never reaches elsif
which
means session[:incidentSearch] was nil so where is params being set to
nil

Please help me understand why is params nil

thanks in advance
-daya

On Tue, 2006-08-08 at 13:35 -0500, linux user wrote:

session[:incidentSearch].empty?
search criteria."

if params[:routeNum] and !params[:routeNum].empty? # <=== params

final params.nil?=true


The funny thing is for first search the control never reaches elsif
which means session[:incidentSearch] was nil so where is params being
set to nil

Please help me understand why is params nil

thanks in advance


on this error screen…there should be a link to the session variables
so you can see their values directly by clicking the link.

Craig