From: gabriele renzi Date: 2006-03-30T19:13:42+09:00 Subject: Re: %r regex matching is ignoring my leading zeros Dara Sanderson ha scritto: > First of all, thanks guys for trying to help. > > I changed my model validation to remove the brackets from around the \d. > Still no dice. > > When I tried it irb as Gabriele did it worked fine though. Just doesn't > want to work on the actual form I'm using. > > I'm afraid I dno't know how to test rails as you have here: this is just the the script/console thing in rails >>what version of ruby are you running? >>Maybe it could have been some damn pesky problem like not having >>reloaded the model (this happened to me many times :) ? > > > I'm hosted on Dreamhost so they're on version 1.8.2 of ruby. > > Maybe it does have something to do with conversion to a string. Maybe > I'll try and manipulate it in my controller before saving. > > Any other suggestions? It seem that the problem is hitting before the validation against the regex is actually called, the string is mangled somewhere. Maybe you can try defining your own validation method and checking that the value is the expected one, or if maybe it is truncated as david black suggested.