Reputation: 10378
r1 is an instance of ActiveSupport::HashWithIndifferentAccess
and the following r1 iterate loop was skipped and was not executed (without error):
req_get.each do |r|
if r[0].to_s.include?(model)
sub_hash = ''
r[1].each do |r1|
if sub_hash.present?
sub_hash += '&' + r[0].to_s + '[' + r1[0].to_s + ']=' + r1[1].to_s
else
sub_hash = r[0].to_s + '[' + r1[0].to_s + ']=' + r1[1].to_s
end
end
end
end
Here req_get is value of request.GET. The reg_get.each loop is working fine.
We filled never-wrong code within the r1 do loop and the result is the same (no execution). What's the right way to iterate this HashWithIndifferentAccess
object? This is rails 3.2 app. Also tried r1.map do |k, v| and the problem is the same.
reg_get (request.GET) contain the params[:model] which is passed into controller. The code above was parsing through the reg_get.
Upvotes: 0
Views: 343
Reputation: 141
Use .each do |key, value|
instead of |r1|
and replace r[0]
with k
and r[1]
with v
Upvotes: 1