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.
661ae6e97d0e16c2af2aaf7d197e8387?d=identicon&s=25 Sijo k g (sijo)
on 2008-10-15 10: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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-15 10:34
(Received via mailing list)
On Oct 15, 9:27 am, Sijo Kg <rails-mailing-l...@andreas-s.net> 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
661ae6e97d0e16c2af2aaf7d197e8387?d=identicon&s=25 Sijo k g (sijo)
on 2008-10-15 12: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.