Hi I have the following action, that generates a flash message if a blog is created, how can I get this message to display in my views? thanks # # POST /blogs # POST /blogs.xml def create @blog = Blog.new(params[:blog]) respond_to do |format| if @blog.save flash[:notice] = ''Blog was successfully created.'' format.html { redirect_to blog_url(@blog) } format.xml { head :created, :location => blog_url(@blog) } else format.html { render :action => "new" } format.xml { render :xml => @blog.errors.to_xml } end 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 -~----------~----~----~----~------~----~------~--~---
On 5/19/07, adam <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi > > I have the following action, that generates a flash message if a blog is > created, > > > how can I get this message to display in my views? > > thanks > > # > # POST /blogs > # POST /blogs.xml > def create > @blog = Blog.new(params[:blog]) > > respond_to do |format| > if @blog.save > flash[:notice] = ''Blog was successfully created.'' > format.html { redirect_to blog_url(@blog) } > format.xml { head :created, :location => > blog_url(@blog) } > else > format.html { render :action => "new" } > format.xml { render :xml => @blog.errors.to_xml } > end > end > end > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Andrei Maxim http://andreimaxim.ro --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I understand that that should pass teh flash hash to the page view, however when I do somthing like this, nothing is displayed. If the <%if flash-%> part is removed, an error is shown on most pages due to a nil object. any suggestions? <%if flash-%> <%if flash[:notice] || flash[:alert] -%> <p id="flashMessage" class="message <%= flash[:notice] ? ''good'' : ''bad'' -%>"> <%= flash[:notice] || flash[:alert] %> </p> <% end -%> <%end-%> Andrei Maxim wrote:> On 5/19/07, adam <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> thanks >> format.html { redirect_to blog_url(@blog) } >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > Andrei Maxim > http://andreimaxim.ro-- 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 -~----------~----~----~----~------~----~------~--~---