Hi All
I am trying to implement a functionality where a user clicks on “Back to
Search Results” link he is taken to the search result screen. For this I
am
storing his search criteria (params object) in session. Here is my code
def search
logger.debug(“params.nil?=#{params.nil?}”) # this prints
'params.nil?=false’
<=== params is NOT nil at this point
if session[:incidentSearch].nil? or
session[:incidentSearch].empty?
params.each{|k,v| logger.debug(“key: #{k}, value: #{v}”)} #this
prints
the key value pairs perfectly
logger.debug(“params=#{params.to_s}”) # this prints
‘params.nil?=false’ <===
params is NOT nil at this point
s=params.dup
params=s
logger.debug(“params=#{s.to_s}”)
if params[:routeNum].nil? or params[:routeNum].empty? <===
params
is NOT nil at this point
flash[:warning] = “Don’t try stupid things…Enter some search
criteria.”
redirect_to :back and return
elsif !params[:routeNum].empty? and one more condition
flash[:warning] = “Specify only one search criteria Reference# or
Route or
Date (Start and End both)”
redirect_to :back and *return
*end
*
params.each{|k,v| logger.debug(“key: #{k}, value: #{v}”)}
elsif !session[:incidentSearch].nil? and
!session[:incidentSearch].empty?
control never reaches here for the first time the search is done
logger.debug("======> Somebody was here…") # <== control never
reaches here for the first time the search is done
params = session[:incidentSearch] # *<== *control never reaches
here, if
I comment it every thing works fine i.e. params is never nil
puts “*^&^&^(^%%^%&^$%$%$&%$&$&^$&^ Somebody was here…” #
<== control
never reaches here and nothing is printed
*end
- logger.debug(“params.nil?=#{params.nil?}”) # this prints
‘params.nil?=*
true*’ <=== params is NIL at this point.
#proceed with search…
This is a single user development environment. So only one request comes
in
for a search… and the params is nil before I can even proceed with
search.
Can somebody please help me understand where and why is params being set
to
nil???
Oh and if I do the following in my first if
s=params.dup
params=s
everything works fine
-daya