I have this in my form view: <%= error_messages_for ''post'' %> I''m not using form_for, just a regular form_tag: <% form_tag :action => ''save_requirement'' do %> The error messages do not pop up, any suggestions? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 22 Jul 2008, at 19:45, Justin To wrote:> > I have this in my form view: > > <%= error_messages_for ''post'' %> > > I''m not using form_for, just a regular form_tag: > <% form_tag :action => ''save_requirement'' do %> > > The error messages do not pop up, any suggestions?is @post an instance of an activerecord object with some errors? Fred> > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > is @post an instance of an activerecord object with some errors? > > FredYes, controller: def new_requirement @post = Post.new end def save_requirement @post = Post.new(params[:post]) if @post.save redirect_to_index("Thank you for your post!") else redirect_to :action => :new_requirement end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi -- On Tue, 22 Jul 2008, Justin To wrote:> >> >> is @post an instance of an activerecord object with some errors? >> >> Fred > > Yes, > > controller: > > def new_requirement > @post = Post.new > end > > > def save_requirement > @post = Post.new(params[:post]) > > if @post.save > redirect_to_index("Thank you for your post!") > else > redirect_to :action => :new_requirement > end > endIn the failure case, you don''t want to redirect; you want to render. Redirecting triggers a completely new request cycle, with a new controller instance, and all instance variables are reset to nil. So @post will be back to being a new Post instance, which will not have any errors, so no errors will be displayed. If you render, on the other hand, you''ll just be rendering the new_requirement template with the existing @post object, which does have errors. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails July 21-24 Edison, NJ * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ah! Great David! Thanks so much, it works! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---