# Is there a way to AutoParse a string to another type - e.g. if a Date format then date, else if inte

**URL:** <https://www.ruby-forum.com/t/is-there-a-way-to-autoparse-a-string-to-another-type-e-g-if-a-date-format-then-date-else-if-inte/145121>\
**Category:** Rails\
**Created:** [August 6, 2008, 6:57am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-autoparse-a-string-to-another-type-e-g-if-a-date-format-then-date-else-if-inte/145121 "2008-08-06T06:57:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [August 6, 2008, 6:57am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-autoparse-a-string-to-another-type-e-g-if-a-date-format-then-date-else-if-inte/145121/1 "2008-08-06T06:57:28Z")

</div>

Hi,

Is there a way to AutoParse a string to another type - e.g. if a Date  
format  
then date, else if integer than Integer etc, in Rails?

I’m wanting to pass search parameters via a URL, however since  
everything in  
the URL will be a string it would be good to automatically convert a  
string  
to the most likely variable type. In particular differentiating between  
an  
Integer and a Date.

Does this exist somewhere in Ruby already? Or do I have to write  
myself?

Thanks in advance
