# Strange problem with Rails and Tomcat

**URL:** <https://www.ruby-forum.com/t/strange-problem-with-rails-and-tomcat/173238>\
**Category:** Rails\
**Created:** [August 5, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/strange-problem-with-rails-and-tomcat/173238 "2009-08-05T14:17:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [August 5, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/strange-problem-with-rails-and-tomcat/173238/1 "2009-08-05T14:17:43Z")

</div>

Hi all,  
IÂ´m having a strange problem in my rails app hosted on Tomcat:  
The ‘div’ element which stores the validation errors of a model doesnÂ´t  
seem to be ‘refreshed’ after each request,so I end up with the following  
problem:

In the first request:‘5 problems ocurred’  
In the second request:‘10 problems ocurred’

and so on…

Can someone spot what could be the problem?  
Thanks,  
Rafael R.

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [August 5, 2009, 2:22pm UTC](https://www.ruby-forum.com/t/strange-problem-with-rails-and-tomcat/173238/2 "2009-08-05T14:22:02Z")

</div>

Are you updating that DIV with javascript?

On Wed, Aug 5, 2009 at 8:17 AM, Rafael R. \<  
removed\_email\_address@domain.invalid\> wrote:

> and so on…
> 
> ## Can someone spot what could be the problem? Thanks, Rafael R.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

# –

Jim  
[http://www.thepeoplesfeed.com/contribute](http://www.thepeoplesfeed.com/contribute)

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [August 5, 2009, 2:31pm UTC](https://www.ruby-forum.com/t/strange-problem-with-rails-and-tomcat/173238/3 "2009-08-05T14:31:14Z")

</div>

No,IÂ´m not.

IÂ´m just putting \<%= error\_messages\_for :my\_model%\> in all the views  
that requires validation…

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [August 5, 2009, 3:35pm UTC](https://www.ruby-forum.com/t/strange-problem-with-rails-and-tomcat/173238/4 "2009-08-05T15:35:06Z")

</div>

I think I know where the problem is:

For some reason(not worth mentioning) I have to validate the model as  
follows:

errors.each do |error|  
@model.errors.add\_to\_base(error.to\_s)  
end

so I think the ‘errors’ attribute isnÂ´t being cleared after each  
request.How could I do this?

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [August 5, 2009, 3:53pm UTC](https://www.ruby-forum.com/t/strange-problem-with-rails-and-tomcat/173238/5 "2009-08-05T15:53:31Z")

</div>

I tried to make:  
@model.errors.clear

but no effect at all…
