# Validate - message in the flash\[:error\]

**URL:** <https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292>\
**Category:** Rails\
**Created:** [June 2, 2008, 5:22pm UTC](https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292 "2008-06-02T17:22:02Z")\
**Posts on this page:** 6\
**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:** [June 2, 2008, 5:22pm UTC](https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292/1 "2008-06-02T17:22:02Z")

</div>

Hi,

I want to show the validate - message in the flash[:error] - field but I  
can’t find any options.

An example:  
class UserPermission \< ActiveRecord::Base  
validates\_presence\_of :name,  
:message =\> “Please insert a name”  
… |  
end V

flash[:error] = "Error - "

Has anybody a solution for this problem?

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:** [June 2, 2008, 5:28pm UTC](https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292/2 "2008-06-02T17:28:39Z")

</div>

What’s wrong with error\_messages\_for ?

---

<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:** [June 2, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292/3 "2008-06-02T17:34:46Z")

</div>

Thorsten M. wrote:

> What’s wrong with error\_messages\_for ?

Hi Thorsten,

error\_messages\_for and error\_messages\_on destroy the look and feel of  
the application in this case.

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:** [June 2, 2008, 5:40pm UTC](https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292/4 "2008-06-02T17:40:41Z")

</div>

You should check out this post on prettying up error\_messages\_for

[http://www.softiesonrails.com/2008/4/23/better-messages-for-activerecord-validation-errors](http://www.softiesonrails.com/2008/4/23/better-messages-for-activerecord-validation-errors)

best.  
mike

---

<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:** [June 2, 2008, 5:54pm UTC](https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292/5 "2008-06-02T17:54:46Z")

</div>

Thanks Thorsten for your helpful tip.  
@user\_permission.errors.full\_messages() solve my problem.

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:** [June 2, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/validate-message-in-the-flash-error/139292/6 "2008-06-02T17:43:04Z")

</div>

Then most likely the only thing you can do is  
manually going through the errors and add them  
to the flash (or directly display them in the view)

@user\_permission.errors.each\_full do |msg|  
…  
end

will return them one by one as string

or

@user\_permission.errors.full\_messages()

would return an array with all messages.

I’m quite sure, there is no direct way to tell the validators to do  
anything but add the error to the models error object.
