# Rendering from a filter class

**URL:** <https://www.ruby-forum.com/t/rendering-from-a-filter-class/171898>\
**Category:** Rails\
**Created:** [July 10, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/rendering-from-a-filter-class/171898 "2009-07-10T23:57:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [July 10, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/rendering-from-a-filter-class/171898/1 "2009-07-10T23:57:23Z")

</div>

I’m defining an around filter as its own class. The documentation on  
ActionController::Filters::ClassMethods includes this example:

class Authorizer  
# This will run before the action. Redirecting aborts the action.  
def before(controller)  
unless user.authorized?  
redirect\_to(login\_url)  
end  
end

```
# This will run after the action if and only if before did not

```

render or redirect.  
def after(controller)  
end  
end

It also includes the explanatory text, “If before renders or  
redirects, the filter chain is halted and after will not be run”  
implying that these filters can render. What I’m not clear on is how.

In my class, calls to render result in a no such method error. I tried  
calling controller.render, and it turns out that’s protected. I can  
get around this using send, but I doubt that’s actually the right way.  
Does anyone happen to know what the right way is?

---

<div class="post-metadata">

**Author:** ![kelleysislander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f6c823/32.png) [@kelleysislander](https://www.ruby-forum.com/u/kelleysislander)\
**Post date:** [July 12, 2009, 12:50am UTC](https://www.ruby-forum.com/t/rendering-from-a-filter-class/171898/2 "2009-07-12T00:50:31Z")

</div>

The tests for this feature and the implementation of around\_filters  
use controller. **send** , so you’ll likely need the same. The  
documentation appears to be incorrect…

–Matt J.
