Anyone else run into this? /admin/ship displays three orders to be shipped check two orders for shipping hit submit results >> flash = "No orders to be shipped" & list of orders to be shipped is now down to one order hit submit again (no orders checked to ship) results >> flash = "Two orders shipped" & list of one order remaining in to be shipped state If so, any thoughts on fixing it? My guess is that the render partial doesn''t fire the admin.rhtml layout so the flash doesn''t get displayed. But that doesn''t make sense because the flash gets displayed, just one action later than you would expect. Thanks. Ken _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Duane Johnson
2005-Jun-21 14:11 UTC
Re: Depot App - Shipping page has Flash irregularities
> If so, any thoughts on fixing it? > > My guess is that the render partial doesn''t fire the admin.rhtml > layout so the flash doesn''t get displayed. But that doesn''t make > sense because the flash gets displayed, just one action later than > you would expect.Are you sure that there''s a redirect in between? The flash will not show on a page unless it''s the next page load from the browser. If you want it to show immediately (without redirecting) use flash.now. Duane Johnson (canadaduane) _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
flash.now does show the flash message immediately when I first hit the the /admin/ship page... Problem still remains. The flash message with the correct count shows up on the second submit. from view: <%= form_tag(:action => "ship") %> from controller: def ship count = 0 if things_to_ship = params[:to_be_shipped] count = do_shipping(things_to_ship) end count_text = pluralize(count, "order") flash[:notice] = "#{count_text} marked as shipped" @pending_orders = Order.pending_shipping end do_shipping marks the orders as shipped. View contains render_collection_of_partials( "order_line", @pending_orders) to re-get the pending orders to be shipped. Form submits to itself. hmmm... _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Duane Johnson
2005-Jun-21 18:04 UTC
Re: Depot App - Shipping page has Flash irregularities
On Jun 21, 2005, at 11:51 AM, Ken Barker wrote:> flash.now does show the flash message immediately when I first hit > the the /admin/ship page... > > Problem still remains. The flash message with the correct count > shows up on the second submit. >Are you trying to get the flash[:notice] to always appear? It seems from your controller''s ''ship'' action that you''re setting the flash regardless of whether the request is a :get or a :post. Is that correct? If so, why not just use a template variable, e.g. @marked = "# {count_text} marked as shipped" and then display that in your view <% = @marked %>.> from view: > <%= form_tag(:action => "ship") %> > > from controller: > def ship > count = 0 > if things_to_ship = params[:to_be_shipped] > count = do_shipping(things_to_ship) > end > count_text = pluralize(count, "order") > flash[:notice] = "#{count_text} marked as shipped" > @pending_orders = Order.pending_shipping > end >Otherwise, if you want the flash[:notice] message to only show on the submit, did you try this? if @request.post? flash.now[:notice] = "@{count_text} marked as shipped"end Duane Johnson (canadaduane) _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Jun 21, 2005, at 8:59 AM, Ken Barker wrote:> Anyone else run into this? >I''ll dig into this here next week--it might be a Rails version thing (or it could be a stupid bug on my part). Thanks Dave
On Jun 21, 2005, at 8:59, Ken Barker wrote:> Anyone else run into this? > > /admin/ship displays three orders to be shipped > check two orders for shipping > hit submit > results >> flash = "No orders to be shipped" & list of orders to be > shipped is now down to one order > hit submit again (no orders checked to ship) > results >> flash = "Two orders shipped" & list of one order > remaining in to be shipped state > > If so, any thoughts on fixing it? > > My guess is that the render partial doesn''t fire the admin.rhtml > layout so the flash doesn''t get displayed. But that doesn''t make > sense because the flash gets displayed, just one action later than you > would expect.This is strange: I can''t reproduce this. Does anyone else see these symptoms? Cheers Dave