controller - Rails life time of params variable -


in standard "index" method of controller set value in params hash in order use in view if it's not initialized yet in other case nothing.

def index   params[:my_value] ||= {} end 

when use include? method on params[:my_value] in view, there's error evaluating nil.include?

why there's such error if params[:my_value] cannot nil. if it's nil, value should initialized {}, that's ||= operator does. can problem here?

the solution in merge method. turned out

a = b.merge(a)  

and

a.merge(b) {|key, v1, v2| v1 } 

do different things , in first case(which wrong) nil appears somewhere. haven't figured out yet why because merge method return hash , when replaced first variant second ok. don't see problem...


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -