Jim Lindley Notes

Controller Exception Handling

September 23rd, 2007

ActionController now includes rescuefrom, which can be used instead of rescue/action/in/public, and fits the other Rails controller filtering and callback methods style.

class PagesController < ActionController::Base
  rescue_from Page::PageNotPublic, :with => :require_login

  ... controller actions

  protected
    def require_login
      ... redirects
    end
end

Changeset #7597

Sorry, comments are closed for this article.