# Validation problem! please help!

**URL:** <https://www.ruby-forum.com/t/validation-problem-please-help/133796>\
**Category:** Rails\
**Created:** [April 3, 2008, 6:16pm UTC](https://www.ruby-forum.com/t/validation-problem-please-help/133796 "2008-04-03T18:16:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 6:16pm UTC](https://www.ruby-forum.com/t/validation-problem-please-help/133796/1 "2008-04-03T18:16:21Z")

</div>

Hi to all,

i’ve the following validation in my model:

class User \< ActiveRecord::Base  
acts\_as\_mappable :default\_units =\> :kms,  
:default\_formula =\> :flat,  
:lat\_column\_name =\> :latitudine,  
:lng\_column\_name =\> :longitudine  
has\_many :neighborgs  
has\_many :blacklists  
has\_many :calls  
validates\_format\_of :mac\_address, :with  
=\>/^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i,  
:on =\> :create,  
:on =\> :update,  
:message =\> "MAC ADDRESS NON CORRETTO, IL FORMATO CORRETTO  
E’: 000b8209bcae "

validates\_uniqueness\_of :mac\_address  
validates\_presence\_of :nome, :cognome, :interno, :indirizzo,  
:cap, :numero\_civico, :telefono\_abitazione, :password, :mac\_address,  
:sncpe  
validates\_numericality\_of :numero\_civico, :cap, :interno  
validates\_format\_of :cap, :with =\> /^[0-9]{5}$/i,  
:on =\> :create,  
:on =\> :update,  
:message =\> “INSERIRE UN CAP VALIDO!!!”

when i insert from the web inferface a wrong value, i’m not redirected  
to the web insertion page, but i see on my browser the error “Template  
is missing” !!!

I really don’t know what is the problem, because all the validations  
work fine!!!

thanks in advance

Andrea

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 6:26pm UTC](https://www.ruby-forum.com/t/validation-problem-please-help/133796/2 "2008-04-03T18:26:51Z")

</div>

if your validations work fine and you get a template error, then most  
likely the error is in the controller code (or the template is missing).  
could you post that? and the full error message, so we can see which  
template is missing…

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 6:34pm UTC](https://www.ruby-forum.com/t/validation-problem-please-help/133796/3 "2008-04-03T18:34:48Z")

</div>

> could you post that? and the full error message, so we can see which  
> template is missing…

Yes, i’ve founded the problem…  
My mistake, in the controller 🙂 !!!

Thanks!!!

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [April 3, 2008, 6:38pm UTC](https://www.ruby-forum.com/t/validation-problem-please-help/133796/4 "2008-04-03T18:38:18Z")

</div>

On 3 Apr 2008, at 17:16, Andrea C. wrote:

> I really don’t know what is the problem, because all the validations  
> work fine!!!

It’s probably something wrong with your controller, but you haven’t  
shown any of that file.

Fred
