Hi! Is it possible to render the action within the after_filter method, or is the rendering performed before? I have something like this: class FooController after_filter :send def a @content=... end def b @content=.. end protected def send send_data(@content,...) end end However, when calling the action a or b, the @content doesn't get sent, but instead rails shows an error message abour missing template.
on 2006-05-11 19:15
on 2006-05-12 17:55
Hi, On May 11, 2006, at 1:15 PM, Esad Hajdarevic wrote: > @content=... > > However, when calling the action a or b, the @content doesn't get > sent, > but instead rails shows an error message abour missing template. Here's a bit of guessing... The response body already has the content by the time the filter is run, well, it does by the time the around filters are run so I assume the after filters too. So I'd guess that rails is looking for its response content before the filters are run -- this makes sense since the after filters are supposed to have access to whatever is being returned. Try adding a 'return false' at the end of the a and b methods -- if that doesn't stop the template error then something else is wrong. The send_data may still not work from the filter, if it doesn't, try writing "response.body = @content" (and you'll have to get the headers setup properly as well). (note that if you are using around filters the controller is the argument and you write something like: "controller.response.body = controller.content" so make sure that the @content attribute is visible). Cheers, Bob > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails ---- Bob Hutchison -- blogs at <http://www.recursive.ca/ hutch/> Recursive Design Inc. -- <http://www.recursive.ca/> Raconteur -- <http://www.raconteur.info/> xampl for Ruby -- <http://rubyforge.org/projects/xampl/>