devise 1.4.9 で after_sign_out_path_for がうまく働かない

deviseを用いたセッション管理において、ログアウトした後の処理がおかしくなった。ログアウトした後の遷移先を変更するためには、after_sign_out_path_for を上書きすればよいとのこと。

ところが、どうもうまく動かない。after_sign_out_path_for は gemライブラリーのインストール先/devise-1.4.9/app/controllers/devise/sessions_controller.rb の destroy で呼び出されている。

# GET /resource/sign_out
  def destroy
    signed_in = signed_in?(resource_name)
    Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
    set_flash_message :notice, :signed_out if signed_in
    # We actually need to hardcode this, as Rails default responder doesn't
    # support returning empty response on GET request
    respond_to do |format|
      format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
      format.all do
        method = "to_#{request_format}"
        text = {}.respond_to?(method) ? {}.send(method) : ""
        render :text => text, :status => :ok
      end
    end
  end

logger.debugを書き込んで動作を確認したところ、以下の部分のブロック内でafter_sign_out_path_forが呼び出されていない。

format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) } 
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) } 
logger.debug(debug: #{after_sign_out_path_for(resource_name)})

というようにafter_sign_out_path_forを呼び出してやるとちゃんと呼び出されるので、ブロック内が処理されていない様子。

any というメソッドClass: ActionController::MimeResponds::Collector#anyとして定義されている。

また、ログアウト時にはWebRickのログは以下のように出力されている。

Started GET "/users/sign_out.2?" for 127.0.0.1 at Fri Nov 11 17:18:25 +0900 2011
  Processing by Devise::SessionsController#destroy as 
Completed 406 Not Acceptable in 152ms

この406は、今日とは違う明日:respond_toで指定されていないformatは406 Not Acceptableが返ってくるとのこと。devise/sessions_controller.rb#destroy 中の *navigational_formats の中身は「html」だったので、そんな変なフォーマットでもないと思う。format.all の動作をみないといけないのだろうか?でも、このメソッドがどこに定義されているのかがわからない。

私の理解度だとここまでしか追えなかったのでとりあえずペンディング