Redirect does not show error_messages


#1

Hi
In the view I have
<%= error_messages_for :problem%>
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


#2

On Oct 15, 9:27 am, Sijo Kg removed_email_address@domain.invalid wrote:

@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


#3

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 >>”}) %>

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