Controller integer param converted to string in 3.1rc5

I've just upgraded from Rails 3.0.7 to 3.1rc5, and am getting some functional test failures with an existing app.

When I call a controllers create or update action. e.g. :

   post :create, :modelname => update

on return, the only integer param passed in has been changed type from e.g. 30 to "30". The other params (strings and a boolean) are ok.

This happens for different tests - e.g. whether the create is successful, or fails due to a param failing validation, or the user not being logged in (I use devise), the result is always the same. This makes me suspect that the issue is not something in my controller/ model.

Has anything changed in this area in Rails 3.1 ?

I thought params were always strings. Possibly (probably?) I am wrong.

Colin

I've just upgraded from Rails 3.0.7 to 3.1rc5, and am getting some functional test failures with an existing app.

When I call a controllers create or update action. e.g. :

  post :create, :modelname => update

on return, the only integer param passed in has been changed type from e.g. 30 to "30". The other params (strings and a boolean) are ok.

I thought params were always strings. Possibly (probably?) I am wrong.

They've always been strings for me. I wonder (haven't looked) if when one does:

post :create, :some_number => 123

If in pre 3.1 rails it wasn't converting it to a string, but passing them as is. Perhaps 3.1 converts them to a string so it's identical to how they'd come in from the browser?

Just a guess...

For clarity, I was referring to the "update" object above being changed (it's a hash, created by factory girl gems attributes_for method).

I guess at some point there is Rails code which converts this to string params for passing to the controller ? Maybe now in 3.1rc1, this also changes the update object ?

Possibly - but note that passing non-string values to a controller in a functional test is a great way to cause really weird bugs. The live code will DEFINITELY be getting strings, so your controllers should be expecting them that way...

--Matt Jones

For clarity, I was referring to the "update" object above being changed (it's a hash, created by factory girl gems attributes_for method).

I guess at some point there is Rails code which converts this to string params for passing to the controller ? Maybe now in 3.1rc1, this also changes the update object ?

Possibly - but note that passing non-string values to a controller in a functional test is a great way to cause really weird bugs. The live code will DEFINITELY be getting strings, so your controllers should be expecting them that way...

There is a small exception to this. If you are POST'ing XML the values will be typecast.