filterrific icon indicating copy to clipboard operation
filterrific copied to clipboard

Autoconverting to Fixnum strips out leading zero

Open gearoidoceallaigh opened this issue 8 years ago • 1 comments

Hi,

I have a phone_number field on my model where phone numbers can begin with a 0 (eg. 01987654)

I wish to filter records based on this field but the leading zero is removed because filterrific automatically converts the input to Fixnum and thus removes the leading zero.

Is there any way to prevent this autoconversion?

PS. Great library - thanks so much!

gearoidoceallaigh avatar Sep 07 '16 08:09 gearoidoceallaigh

@gearoidoceallaigh thanks for using Filterrific. Currently there is no simple way to prevent the autoconversion. I'd suggest you prefix it with something like '_' (underscore). That will prevent the casting to Int. Then you'd remove the leading underscore before you actually use the param in the scope.

I'm reviewing currently if we can get rid of the Int parsing alltogether.

jhund avatar Nov 07 '16 00:11 jhund