In my action, if I do nothing unusual, then I expect to render to the
regular place. If I override @success_controller and/or @success_action, then my action code can set up the success target.
Unfortunately, when I try to do this, I get a DoubleRenderError, which I
am sure is because the default render is already done in my action
before I attempt to do either render in the after filter.
Can this be done, or do I have to resign myself to only setting the
target in the after_filter, and then doing the rendering in the action
method itself?
It looks like theoretically, at least, I could manipulate the response
body directly, which I think implies that I would be rewriting render to
a degree.
Of course, it’s all a non-issue unless I could override the default
rendering behavior.
But one way that you could get similar behavior would be to use
redirect_to in a before filter to respond to the test, whatever it is.
But in order to do this, you would have to always redirect_to every
action that the before filter was applied to, in order to get the before
filter to run.
Bottom line: It would be nice to have the ability to control/impact
rendering for an action outside of the action method itself.
You can definitely modify the response in an after_filter: we have a
bunch of actions that produce xml, and an after filter that runs the xml
through an xslt filter (and the user only ever sees the resulting html)
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.