I have a controller that looks exactly like the code below. My problem is that I can''t get the flash[:notice]''s to show up on the page. Interestingly though, I when I test this controller, I have tests that make it go down both of the unhappy paths (the ActiveRecord::RecordInvalid exception and ''some_boolean_expression should''ve been true'') and these tests pass when ''assert_match'' on the flash... assert_match(/Error saving:/, flash[:notice]) and assert_match(/some_boolean_expression should''ve been true/, flash[:notice]) respectively Any thoughts on what could possibly explain the fact I can''t see the flash in the browser? TIA... ===== controller code ==== def do_the_action if (some_boolean_expression) begin model = ModelObject.new(:attribute1 => "1", :attribute2 => "2") model.save! path = "a/path" redirect_to(path) rescue ActiveRecord::RecordInvalid => error # findme: this flash notice doesn''t seem to be showing up; logging it for now @@log.error("Error saving: #{error}") flash[:notice] = "Error saving: #{error}" redirect_to :action => "show" end else # findme: this flash notice doesn''t seem to be showing up; logging it for now @@log.error("some_boolean_expression should''ve been true") flash[:notice] = "some_boolean_expression should''ve been true" redirect_to :action => "show" end end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bryan Noll wrote:> I have a controller that looks exactly like the code below. My problem > is that I can''t get the flash[:notice]''s to show up on the page.> Any thoughts on what could possibly explain the fact I can''t see the > flash in the browser?what do your views look like? the controller certainly looks like it''s setting the flash (and your tests verify that) so including somewhere in your "show.rhtml" the line "<%= flash[:status] %>" should definitely be showing up. -- 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 -~----------~----~----~----~------~----~------~--~---
Like you say, my view template has ''<%= flash[:notice] %>'' in it. I''m using hobo''s dryml though instead of rhtml, so that may be contributing to the problem. I''ll check over on their list. Thanks... Matthew Rudy wrote:> Bryan Noll wrote: > >> I have a controller that looks exactly like the code below. My problem >> is that I can''t get the flash[:notice]''s to show up on the page. >> > > >> Any thoughts on what could possibly explain the fact I can''t see the >> flash in the browser? >> > > what do your views look like? > the controller certainly looks like it''s setting the flash (and your > tests verify that) > so including somewhere in your "show.rhtml" the line "<%= flash[:status] > %>" should definitely be showing up. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hopefully this will help someone else. The problem was that the first line of the ''show'' action that the ''do_the_action'' action was redirecting to did this: flash[:notice] = nil It threw me off since the flash was being picked up in the test. Bryan Noll wrote:> I have a controller that looks exactly like the code below. My > problem is that I can''t get the flash[:notice]''s to show up on the > page. Interestingly though, I when I test this controller, I have > tests that make it go down both of the unhappy paths (the > ActiveRecord::RecordInvalid exception and ''some_boolean_expression > should''ve been true'') and these tests pass when ''assert_match'' on the > flash... > > assert_match(/Error saving:/, flash[:notice]) > > and > > assert_match(/some_boolean_expression should''ve been true/, > flash[:notice]) > > respectively > > Any thoughts on what could possibly explain the fact I can''t see the > flash in the browser? > > TIA... > > > ===== controller code ====> > def do_the_action > if (some_boolean_expression) > begin > model = ModelObject.new(:attribute1 => "1", :attribute2 => "2") > model.save! > path = "a/path" redirect_to(path) > rescue ActiveRecord::RecordInvalid => error > # findme: this flash notice doesn''t seem to be showing up; > logging it for now > @@log.error("Error saving: #{error}") > flash[:notice] = "Error saving: #{error}" > redirect_to :action => "show" > end > else > # findme: this flash notice doesn''t seem to be showing up; > logging it for now > @@log.error("some_boolean_expression should''ve been true") > flash[:notice] = "some_boolean_expression should''ve been true" > redirect_to :action => "show" > end > end >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---