Forum: Ruby on Rails Experimental plugin: Rack-based after_filter-ish behavior

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
David A. Black (Guest)
on 2009-01-11 01:51
(Received via mailing list)
Hi --

I've been working on a per-action Rack-based after_filter-like
facility, and I thought others might like to see the experiment (and I
do consider it experimental). It's a plugin called after_middles, at:


It works like this (assuming Rails 2.3/edge):

   # Define something like this somewhere:
   class MyRackApp
     def call(env)
       # you already have @app here for the
       # middleware chain

   # Then in your controller:
   class ThingsController < ApplicationController
     after_middle MyRackApp, :only => :show
     def show

It maintains its own middleware stack, and after_middle itself is just
a wrapper around before_filter that adds to that stack.

I'm not sure yet how useful it will be (either for adding
functionality or for speed), except it's already served one of its
purposes, namely to help me learn more about the recent controller
code and the implementation of the middleware integration. Anyway, if
interested, have a look, and let me know if you have any


David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training:
Coming in 2009: The Well-Grounded Rubyist ( => Independent, social wishlist management!
This topic is locked and can not be replied to.