Forum: Ruby on Rails redirect does not show error_messages

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sijo k. (Guest)
on 2008-10-15 12:27
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
Frederick C. (Guest)
on 2008-10-15 12:34
(Received via mailing list)
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
Sijo k. (Guest)
on 2008-10-15 14:02
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
This topic is locked and can not be replied to.