How do you access Devise controllers?

后端 未结 5 1672
野趣味
野趣味 2020-12-04 11:04

Are controllers in devise automatically generated? How do you access them?

I know for views you do rails generate devise_views.

5条回答
  •  离开以前
    2020-12-04 12:01

    To define custom controller behavior,

    see @ErikTrautman's answer.

    But if you're trying to understand what Devise is doing under the hood,

    you must inspect the source (specifically, in the project root's app/ directory). @MatheusMoreira provides a link to the source on GitHub, but if you'd rather browse it locally in your own text editor, you can find the install location of the Devise gem with gem which devise.

    For instance, to see Devise::SessionsController:

    $ vim $(gem which devise | sed 's|\(.*\)\(/.*\)\{2\}|\1|')/app/controllers/devise/sessions_controller.rb
    

    (Or, you could just clone the git repo and poke around that way.)

    $ git clone https://github.com/plataformatec/devise
    $ cd devise
    $ vim app/controllers/devise/sessions_controller.rb
    

提交回复
热议问题