Skip to content

Instantly share code, notes, and snippets.

@bluemont
Created April 22, 2013 04:32
Show Gist options
  • Star 37 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save bluemont/e304e65e7e15d77d3cb9 to your computer and use it in GitHub Desktop.
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…
# 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
@pedroassumpcao
Copy link

Thanks!

@chubchenko
Copy link

Thanks!

@benbonnet
Copy link

great!

@pcanterini
Copy link

Life saver! Thank you.

@Gaurav2728
Copy link

Thanks ...it's really work......!!

@huertanix
Copy link

@guyisra
Copy link

guyisra commented Feb 5, 2014

👍

@Verkalets
Copy link

Thanks!

@melhotiby
Copy link

Thanks 👍

@diegobernardes
Copy link

Thanks!

@Ruby-rocker
Copy link

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

@juddey
Copy link

juddey commented May 11, 2015

Thanks @Ruby-rocker, works good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment