# Don't get the right error message on submit a form

**URL:** <https://www.ruby-forum.com/t/dont-get-the-right-error-message-on-submit-a-form/144914>\
**Category:** Rails\
**Created:** [August 4, 2008, 11:05am UTC](https://www.ruby-forum.com/t/dont-get-the-right-error-message-on-submit-a-form/144914 "2008-08-04T11:05:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [August 4, 2008, 11:05am UTC](https://www.ruby-forum.com/t/dont-get-the-right-error-message-on-submit-a-form/144914/1 "2008-08-04T11:05:46Z")

</div>

Hi,

I’ve got a small problem with my validation of a model. I have a user  
and a user\_setting table. The user has all main informations and the  
user\_setting - table has addional data like his first name etc. All  
necessary input field are in one form and connect with field\_for to the  
right model. All possible input fields of the user\_setting table are  
saved in a configuration file. If the form will be submitted the  
user\_setting model check the value of the input fields with the given  
informations of the configuration file. Now is my problem that message  
in combination with the Globalite - plugin allways repeat  
“ **localization\_missing** ” and not the right message of the  
check\_settings - method. Antoher problem is that the input field of  
user\_setting model are not red marked in the create form.

My Model:  
class UserSetting \< ActiveRecord::Base  
validate :check\_settings

belongs\_to :user, :foreign\_key =\> “user\_id”

validates\_presence\_of :name, :message =\> :message\_insert\_name.l  
validates\_presence\_of :setting\_type, :message =\> “Include type”

protected  
def check\_settings  
yaml\_settings =  
LoadConfigurations.load\_configurations(“user\_settings”)  
if yaml\_settings[self.setting\_type][self.name][‘necessary’] == 1  
errors.add(self.name, :notice\_no\_value\_set.l(“Error! No value  
set!”)) if self.value.blank?  
elsif !yaml\_settings[self.setting\_type][self.name][‘range’].blank?

```
end

```

end

end

Has anybody some tips to solve these problems?

Regards Eddy

---

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [August 12, 2008, 10:35am UTC](https://www.ruby-forum.com/t/dont-get-the-right-error-message-on-submit-a-form/144914/2 "2008-08-12T10:35:48Z")

</div>

I solve the problem:

If you use this code [http://pastie.org/109132](http://pastie.org/109132) (which a guy post at  
[#75 Complex Forms Part 3 - RailsCasts](http://railscasts.com/episodes/75) ) and include them into the User Model

- validates\_associated :user\_settings =\> all messages 🙂

The problem with the red marked input field isn’t solved yet.

Regards Eddy
