実行環境: ruby 1.9.3 Rails 3.1.3 ログイン認証なんかを実現する際におなじみの before_filter に適用条件をつけてみようというお話です。 ① アクション名で制限をかける :only、:except オプションを使うと、アクション名で適用条件を設定できます。 #{RAILS_ROOT}/app/controllers/application_controller.rbclass ApplicationController < ActionController::Base before_filter :my_filter1, :only => 'index' before_filter :my_filter2, :except => ['index', 'show'] private def my_filter1 end def my_filter2 end