-
-
Save bluemont/e304e65e7e15d77d3cb9 to your computer and use it in GitHub Desktop.
Due to some recent changes in the `rails4` branch of Devise, I needed to update the code I borrowed from
https://gist.github.com/kazpsp/3350730. Here it is. Read more on the [Rails 4 Devise branch README](https://github.com/plataformatec/devise/tree/rails4#strong-parameters). If you want to see what options you can pass into `devise_parameter_sa…
This file contains 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
# controllers/users/registrations_controller.rb | |
class Users::RegistrationsController < Devise::RegistrationsController | |
before_filter :configure_permitted_parameters | |
protected | |
# my custom fields are :name, :heard_how | |
def configure_permitted_parameters | |
devise_parameter_sanitizer.for(:sign_up) do |u| | |
u.permit(:name, :heard_how, | |
:email, :password, :password_confirmation) | |
end | |
devise_parameter_sanitizer.for(:account_update) do |u| | |
u.permit(:name, | |
:email, :password, :password_confirmation, :current_password) | |
end | |
end | |
end |
Thanks!
great!
Life saver! Thank you.
Thanks ...it's really work......!!
"https://github.com/plataformatec/devise/tree/rails4#strong-parameters" seems to be 404ing.
👍
Thanks!
Thanks 👍
Thanks!
Try this for custom fields (:first_name, :last_name) as strong parameter
class RegistrationsController < Devise::RegistrationsController
private
def sign_up_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation)
end
def account_update_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password)
end
end
Thanks @Ruby-rocker, works good :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!