Hi, folks. I am experiencing cognitive dissonance about an unexpected
(and to me, non-intuitive) interaction between flash and
render_component_as_string.
It seems that if a controller action calls render_component_as_string,
sets some flash data, and does a redir, the flash data is lost. It
works as you’d expect if render_component is not called. To illustrate:
class TestController < ApplicationController
def unexpected
render_component_as_string(:controller=>‘test’,
:action=>‘other’)
flash[:notice] = ‘Attention please.’
redirect_to :action => ‘show’
end
def expected
flash[:notice] = ‘Attention please.’
redirect_to :action => ‘show’
end
def show
render_text(flash.inspect)
end
def other
render_text(‘yep’)
end
end
When I hit test/unexpected, I get back an empty hash. Where’d my flash
data go? Why does render_component_as_string seem to make it disappear?
–Colin