mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Merge pull request #3276 from michaelmoulsdale/patch-1
Update README.md - Updated Configuring controllers section
This commit is contained in:
commit
b910f5eb83
1 changed files with 6 additions and 6 deletions
12
README.md
12
README.md
|
@ -289,11 +289,11 @@ If the customization at the views level is not enough, you can customize each co
|
||||||
rails generate devise:controllers [scope]
|
rails generate devise:controllers [scope]
|
||||||
```
|
```
|
||||||
|
|
||||||
If you specify `admins` as the scope, controllers will be created in `app/controllers/admins/`.
|
If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
|
||||||
And the sessions controller will look like this:
|
And the sessions controller will look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class Admins::SessionsController < Devise::SessionsController
|
class Users::SessionsController < Devise::SessionsController
|
||||||
# GET /resource/sign_in
|
# GET /resource/sign_in
|
||||||
# def new
|
# def new
|
||||||
# super
|
# super
|
||||||
|
@ -305,17 +305,17 @@ If the customization at the views level is not enough, you can customize each co
|
||||||
2. Tell the router to use this controller:
|
2. Tell the router to use this controller:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
devise_for :admins, controllers: { sessions: "admins/sessions" }
|
devise_for :users, controllers: { sessions: "users/sessions" }
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Copy the views from `devise/sessions` to `admins/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
|
3. Copy the views from `devise/sessions` to `users/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
|
||||||
|
|
||||||
4. Finally, change or extend the desired controller actions.
|
4. Finally, change or extend the desired controller actions.
|
||||||
|
|
||||||
You can completely override a controller action:
|
You can completely override a controller action:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class Admins::SessionsController < Devise::SessionsController
|
class Users::SessionsController < Devise::SessionsController
|
||||||
def create
|
def create
|
||||||
# custom sign-in code
|
# custom sign-in code
|
||||||
end
|
end
|
||||||
|
@ -325,7 +325,7 @@ If the customization at the views level is not enough, you can customize each co
|
||||||
Or you can simply add new behaviour to it:
|
Or you can simply add new behaviour to it:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class Admins::SessionsController < Devise::SessionsController
|
class Users::SessionsController < Devise::SessionsController
|
||||||
def create
|
def create
|
||||||
super do |resource|
|
super do |resource|
|
||||||
BackgroundWorker.trigger(resource)
|
BackgroundWorker.trigger(resource)
|
||||||
|
|
Loading…
Add table
Reference in a new issue