param values are HashWithIndifferentAccess?

I have the following code:

params.each do |k, v|
  if k =~ /something/
    ARClass.find_by_blah(v)
  end
end

The "find_by_blah" call fails to return anything and when I print out
v.class.name, I get HashWithIndifferentAccess.

WTF? Is it unreasonable for me to expect the value of a params hash
element to be String?

Wes

Hey Wes-

  I think your problem with this is that in an iteration over the params hash, the v part can also be another hash in order to support nested hashes in params. So like this:

>> params = { :foo => 'bar', :baz => {:nik => 'nak'}}
=> {:baz=>{:nik=>"nak"}, :foo=>"bar"}
>> params.each {|k,v| p v }
{:nik=>"nak"}
"bar"

  So you see one of the values in that hash is a string but another is a nested hash. I think this is what is causing you confusion. You need to write that method in a recursive way to it traverses the sub hashes as well as the top level ones

Cheers-
-Ezra