Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2291 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

flash

Reported by: rick Assigned to: scott@elitists.net
Priority: low Milestone: 1.x
Component: ActionPack Version:
Severity: normal Keywords: flash component
Cc: technoweenie@gmail.com, rails@halffull.org,maze@strahlungsfrei.de,j.auricchio@gmail.com

Description

Flash values are not preserved in controllers invoked by render_component. The callee controller's after_filter wipes the flash set from a caller controller.

Attachments

component_flash_fix.2322.diff (2.6 kB) - added by rick on 09/24/05 18:17:16.
component_flash_fix_2.2322.diff (3.4 kB) - added by divoxx on 09/24/05 18:18:14.
Totally different approach. Adds a component_call? method that could potentially be used in other cases like this
component_flash_fix.2322.2.diff (2.7 kB) - added by rick on 09/24/05 18:53:10.
added test to make sure flash was cleared properly.
components_flash.diff (1.9 kB) - added by htonl on 09/24/05 23:50:36.
Patch for #2291

Change History

09/24/05 18:17:16 changed by rick

  • attachment component_flash_fix.2322.diff added.

09/24/05 18:18:14 changed by divoxx

  • attachment component_flash_fix_2.2322.diff added.

Totally different approach. Adds a component_call? method that could potentially be used in other cases like this

09/24/05 18:53:10 changed by rick

  • attachment component_flash_fix.2322.2.diff added.

added test to make sure flash was cleared properly.

09/24/05 19:12:46 changed by rick

divoxx's patch doesn't seem to work if the flash is called in one component, and retrieved in another. The flash seems to stay forever.

09/24/05 23:50:36 changed by htonl

  • attachment components_flash.diff added.

Patch for #2291

09/24/05 23:52:23 changed by htonl

  • owner changed from David to scott.

I've got a shorter version that touches less. I appreciate the investigation and (very much) the tests.

09/25/05 00:05:23 changed by rick

Works great in my app. thanks.

09/25/05 10:20:28 changed by anonymous

  • cc changed from technoweenie@gmail.com to technoweenie@gmail.com, rails@halffull.org.

09/25/05 10:27:34 changed by anonymous

  • cc changed from technoweenie@gmail.com, rails@halffull.org to technoweenie@gmail.com, rails@halffull.org,maze@strahlungsfrei.de.

09/27/05 11:02:34 changed by htonl

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [2363].

10/23/05 06:03:10 changed by j.auricchio@gmail.com

  • cc changed from technoweenie@gmail.com, rails@halffull.org,maze@strahlungsfrei.de to technoweenie@gmail.com, rails@halffull.org,maze@strahlungsfrei.de,j.auricchio@gmail.com.
  • status changed from closed to reopened.
  • resolution deleted.

Hi!

Scott's patch as it made it into 0.14.1 did *not* work for me. The call to after_filter should be prepend_after_filter, or else the flash will be kept after it's already been swept.

I commented out the after_filter call in lib/action_controller/components.rb line 54 and put a breakpoint there instead

from script/breakpointer:3irb(#<PageController:0x26e7e30>):003:0> c.after_filters => [:sweep_flash, :clear_persistant_model_associations] irb(#<PageController:0x26e7e30>):004:0> c.after_filter {|c| flash.keep } => [:sweep_flash, :clear_persistant_model_associations, #<Proc:0x025affa4@(irb):4>]

Note the Proc for flash.keep runs _after_ sweep_flash has cleared it out. There's no longer anything to keep.

instead,

irb(#<PageController:0x26e8560>):003:0> c.prepend_after_filter {|c| flash.keep} => :sweep_flash, :clear_persistant_model_associations

Now everything gets kept before the sweeper gets a shot at it.

By running the two back to back I can quickly confirm that the flash gets eaten with after_filter and does not get eaten with prepend_after_filter.

I'm on an 0.14.1 app upgraded just earlier tonight from 0.13.1. Thanks! =]

10/24/05 21:38:18 changed by htonl

Using prepend does not work and fails the unit tests. However, I'm going to leave this ticket open for now because I have to come up with a completely different solution. This method is consuming vast amounts of memory (see Ticket #2589) and cannot continue to exist.

10/24/05 22:04:49 changed by j.auricchio@gmail.com

FWIW, the problem I was encountering was that the flash would be empty when the layout was rendered, if render_component had ever been called in that action. That seems to be a different problem than the one in the unit test. Just a heads up as you go about fixing the problem. =]

10/25/05 00:41:29 changed by htonl

Could you please update to rev [2722] and test out your set up?

01/22/06 02:01:50 changed by david

  • owner changed from scott to scott@elitists.net.
  • status changed from reopened to new.

Is this ticket still valid? If not, please close.

02/27/06 00:28:58 changed by scott@elitists.net

  • status changed from new to closed.
  • resolution set to fixed.

Components have since been refactored and this should no longer be relevant.

04/21/06 10:36:02 changed by anonymous

  • priority changed from normal to lowest.
  • summary changed from [PATCH] render_components clobber the flash... this is me clobbering back to flash.
  • version deleted.
  • milestone set to 1.x.