reg exp

On Sun, Jan 3, 2010 at 3:02 PM, jsoo <[email protected]> wrote:
> Hey
>
> I'm running into an small issue with searching a zip codes table,
> where some zip codes contain 1 or more leading zeros.  This problem
> could be fixed with some database level hacking -- but I'd rather
> attack the problem in rails.
>
> Zip codes are stored in the zip code table with leading zeros dropped.
> 01234 becomes 1234.  Thus, when someone searches via the website for
> 012345, it will not find any results.
>
> I'm looking to write a method (probably in the Zipcode model) to
> remove any leading zeros from an incoming search request, before it
> gets passed into sql calls.
>
> I looked into callbacks, but those appears to only be useful when
> creating/saving/updating/deleting data, whereas I need to address
> searching.
>
> Any suggestions on the correct/best way to do this?  Again, I'm
> looking for a rails solution, not a database level solution.
>
> Thanks
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to