-
-
Save kazpsp/3350730 to your computer and use it in GitHub Desktop.
StrongParameters with Devise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/users/password_controller.rb | |
class Users::PasswordsController < Devise::PasswordsController | |
def resource_params | |
params.require(:user).permit(:email, :password, :password_confirmation) | |
end | |
private :resource_params | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/users/registrations_controller.rb | |
class Users::RegistrationsController < Devise::RegistrationsController | |
def resource_params | |
params.require(:user).permit(:name, :email, :password, :password_confirmation) | |
end | |
private :resource_params | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
devise_for :users, :controllers => {:registrations => "users/registrations", :passwords => "users/passwords"} |
thanks for the update
Thanks!
Thanks ! :)
Checkout @sferik's fork if you are using recoverable or want to let users change their password...
better version
You need to add a few more params to the list or else you will get errors. Saved me some trouble.
I've made a gist based on the lazy suggestion for devise that handles multiple models at https://gist.github.com/mastfish/5702796 .
It saves having to create custom controllers.
Thanks )
Thanks 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
rails4
branch of Devise has some recent changes that are important for this discussion. See: heartcombo/devise@3ed0dc5 Or just view the README: https://github.com/plataformatec/devise/tree/rails4#strong-parametersI made a Gist showing the code I use: https://gist.github.com/bluemont/e304e65e7e15d77d3cb9