DRYing up your controllers in rails with find_filter plugin

http://matthewbass.com/2008/08/08/finder_filter-gem-released/

This:

class UsersController < ActionController::Base
  before_filter :find_user, :only => [:show, :edit]

  def show
    # do something with @user
  end

  def edit
    # do something with @user
  end

  def find_user
    @user = User.find(params[:id)
  end
end

to this:

class UsersController < ActionController::Base
  finder_filter :only => [:show, :edit]

  def show; end
  def edit; end
end

Comments