Hey guys,
I’d like to hear people’s opinions on modifying the filter class methods such that we could stack declarations. Take the following setup as an example:
class DashboardController < ApplicationController
include Filters
include RssPresenter
before_filter :get_user, :only => [:index]
def some_action_that_doesnt_require_user
end
end
module Filters
def get_user
@user = User.find(params[:id])
end
private :get_user
end
module RssPresenter
def self.included(base)
base.before_filter :get_user, :only => [:rss]
end
def rss
#stuff
end
end
Currently, get_user will not be called on RssPresenter#rss because the before_filter call in DashboardController overrides the base.before_filter in RssPresenter. Rewriting RssPresenter like this:
module RssPresenter
def self.included(base)
base.before_filter :get_user
end
def rss
#stuff
end
end
will not work because then get_user will get called on every action in DashboardController.
Let me know what you guys think of this, and I’ll work on a patch if you’d like.
Thanks,
Ryan