# redirect does not show error\_messages

**URL:** <https://discuss.rubyonrails.org/t/redirect-does-not-show-error-messages/35380>\
**Category:** rubyonrails-talk\
**Created:** [October 15, 2008, 8:27am UTC](https://discuss.rubyonrails.org/t/redirect-does-not-show-error-messages/35380 "2008-10-15T08:27:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [October 15, 2008, 8:27am UTC](https://discuss.rubyonrails.org/t/redirect-does-not-show-error-messages/35380/1 "2008-10-15T08:27:45Z")

</div>

Hi &nbsp;&nbsp;&nbsp;&nbsp;In the view I have \<%= error\_messages\_for :problem%\> &nbsp;&nbsp;In the model I have validations. and in controller inside transaction I have

@problem.save! So suppose an error happens I have redirected to the same view which contains error\_messages ..But my problem is I dont ge the error messages when redirect but get it when render the same

redirect\_to :action =\> 'create\_ui' #This dies not give error messages for problem render :action =\> 'create\_ui' #This gives error messages for problem Why this happens ?Please help

Sijo

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [October 15, 2008, 8:33am UTC](https://discuss.rubyonrails.org/t/redirect-does-not-show-error-messages/35380/2 "2008-10-15T08:33:46Z")

</div>

> @problem.save! So suppose an error happens I have redirected to the same view which contains error\_messages ..But my problem is I dont ge the error messages when redirect but get it when render the same
> 
> redirect\_to :action =\> 'create\_ui' #This dies not give error messages

Because the state of the invalid object is lost when you do a redirect (which is why people typically don't do a redirect)

Fred

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [October 15, 2008, 10:02am UTC](https://discuss.rubyonrails.org/t/redirect-does-not-show-error-messages/35380/3 "2008-10-15T10:02:03Z")

</div>

Hi

Thanks for the reply.Why I used the redirect because I first used render But In the view I have some check boxes One of them like \<%= select( "problem", "problem\_urgency\_id", ProblemUrgency.find(:all).collect {|p| [p.name, p.id] },options ={:prompt =\> "\<\< Select any \>\>"}) %\>

&nbsp;&nbsp;&nbsp;&nbsp;So in the above if I use render(if error happens) what happens is that \<\< Select any \>\> is not shown and only the values from the problem\_urgencies table are shown That is why I used the redirect\_to But it has this problem(Not problem actually)..Could you please suggest how I can solve this?

Thanks in advance Sijo
