deviseを使っている途中に気になっているところ。

deviseを使ってみるとログイン機能のコントローラーは以下のようになっている。


class SessionsController < Devise::SessionsController
~~~~~~~~~~~~~~~~
end
SessionsController はdeviseのDevise::SessionsControllerを継承しているから、
ApplicationControllerに書いたロジックは実行しないのではと思うだろう。

deviseの中身をちょっと調べたいかのソースコードを見つかりました。


8 module Devise
~~~~~~~~~~~~~~~~
201 # The parent controller all Devise controllers inherits from.
202 # Defaults to ApplicationController. This should be set early
203 # in the initialization process and should be set to a string.
204 mattr_accessor :parent_controller
205 @@parent_controller = "ApplicationController"
206
207 # The parent mailer all Devise mailers inherit from.
208 # Defaults to ActionMailer::Base. This should be set early
209 # in the initialization process and should be set to a string.
210 mattr_accessor :parent_mailer
211 @@parent_mailer = "ActionMailer::Base"
~~~~~~~~~~~~~~~~
460 end

うん〜〜〜
なるほど、ちゃんと作っているじゃ〜
継承しているね。
心配なくApplicationControllerはアプリのすべてのcontrollerを継承していると思っていても構わないね。