# Validation error messages

**URL:** <https://www.ruby-forum.com/t/validation-error-messages/82457>\
**Category:** Rails\
**Created:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/validation-error-messages/82457 "2007-01-19T16:30:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skeets](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@Skeets](https://www.ruby-forum.com/u/Skeets)\
**Post date:** [January 19, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/validation-error-messages/82457/1 "2007-01-19T16:30:35Z")

</div>

i’m having a problem getting ahold of the validation error message.

* * *

mileage model:

validates\_presence\_of :title

mileage controller:

def create  
if @mileage.save  
redirect\_to :action =\> ‘list’  
else  
redirect\_to :action =\> ‘new’  
end  
end

def new  
#stuff here  
end

new.rhtml

\<%= error\_messages\_for “mileage” %\>  
#also tried \<%= error\_messages\_for :mileage %\>

* * *

new.rhtml is displayed, but no error message is displayed.

what am i doing wrong?

tia…

---

<div class="post-metadata">

**Author:** ![Skeets](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@Skeets](https://www.ruby-forum.com/u/Skeets)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/validation-error-messages/82457/2 "2007-01-19T16:31:27Z")

</div>

Kinda bad news, you’ll need to save the errors to a flash and roll your  
own  
helper for outputting the errors [I’ve dont this, it’s not that hard] OR  
you’ll have to not redirect\_to :new when @mileage.save fails.  
error\_messages\_for doesn’t work after a redirect.

RSL
