ウェブサービスを作っています。

role_requirement で、一部のコントローラだけ権限を不要とする

restful_authentication プラグインに権限管理機能を追加する role_requirement というプラグインがあります。
rolerequirement - Clean role-based security for restful_authentication (or acts_as_authenticated) - Google Project Hosting
Ruby on Rails/RESTfulAuthenticationに権限管理を追加する「role_requirement」プラグイン - アークウェブシステム開発SandBox


コントローラに require_role を定義していくことで、権限のないユーザのアクセスを拒否することができます。
しかし大量のコントローラに定義したい際、1 つ 1 つのコントローラに定義していくのでは記入漏れの可能性があります。
そこで ApplicationController など、スーパークラスで定義したい場合があるかと思います。
ですがスーパークラスに書いただけでは、ログインコントローラまでアクセスできなくなってしまいます。


この問題を解消するには、スーパークラスに require_role を定義した上で、権限が不要となるクラスには reset_role_requirements! を定義します。

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  include RoleRequirementSystem

  before_filter :login_required
  require_role 'admin'
end


app/controllers/sessions_controller.rb

class SessionsController < ApplicationController
  skip_before_filter :login_required
  reset_role_requirements!
end