== Module == # User authentication mixin for use with Rails controllers. module UserAuthentication # Try something like this ... def self.included(controller) controller.extend(ClassMethods) end # This thing is really a class method of the controller # Put all class methods into a ClassMethods module, and # the included method above extends the controller with # these class methods. module ClassMethods def authentication_required(options = {}) before_filter :authentication_required_filter, options end end end == Controller == require_dependency "user_authentication" class UsersController < ApplicationController include UserAuthentication authentication_required :except => "login" role_required :admin, :only => [ "edit", "update", "destroy" ] def index list render :action => 'list' end # ... snip other methods end