Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
StrongParameters with Devise
# 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
# 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
# config/routes.rb
devise_for :users, :controllers => {:registrations => "users/registrations", :passwords => "users/passwords"}
@nfedyashev

This comment has been minimized.

Show comment
Hide comment

Thank you!

@he9lin

This comment has been minimized.

Show comment
Hide comment
@he9lin

he9lin Sep 13, 2012

I had to add reset_password_token as one of the arguments

he9lin commented Sep 13, 2012

I had to add reset_password_token as one of the arguments

@ethier

This comment has been minimized.

Show comment
Hide comment
@ethier

ethier Mar 17, 2013

Thanks for this.

ethier commented Mar 17, 2013

Thanks for this.

@dannyko

This comment has been minimized.

Show comment
Hide comment
@dannyko

dannyko Mar 20, 2013

the comment "# app/controllers/users/password_controller.rb" should read

app/controllers/users/passwords_controller.rb

dannyko commented Mar 20, 2013

the comment "# app/controllers/users/password_controller.rb" should read

app/controllers/users/passwords_controller.rb

@earnold

This comment has been minimized.

Show comment
Hide comment
@earnold

earnold Mar 23, 2013

Thank you for this! 👍

earnold commented Mar 23, 2013

Thank you for this! 👍

@andreapavoni

This comment has been minimized.

Show comment
Hide comment
@andreapavoni

andreapavoni Mar 26, 2013

I did some changes to handle multiple resources (eg: User and Admin): https://gist.github.com/apeacox/5245821

I did some changes to handle multiple resources (eg: User and Admin): https://gist.github.com/apeacox/5245821

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 22, 2013

The rails4 branch of Devise has some recent changes that are important for this discussion. See: https://github.com/plataformatec/devise/commit/3ed0dc5d9fd56e60a46b9bea0de834d5901638fa Or just view the README: https://github.com/plataformatec/devise/tree/rails4#strong-parameters

I made a Gist showing the code I use: https://gist.github.com/bluemont/e304e65e7e15d77d3cb9

ghost commented Apr 22, 2013

The rails4 branch of Devise has some recent changes that are important for this discussion. See: https://github.com/plataformatec/devise/commit/3ed0dc5d9fd56e60a46b9bea0de834d5901638fa Or just view the README: https://github.com/plataformatec/devise/tree/rails4#strong-parameters

I made a Gist showing the code I use: https://gist.github.com/bluemont/e304e65e7e15d77d3cb9

@istana

This comment has been minimized.

Show comment
Hide comment
@istana

istana May 3, 2013

thanks for the update

istana commented May 3, 2013

thanks for the update

@pawel2105

This comment has been minimized.

Show comment
Hide comment

Thanks!

@deneuxa

This comment has been minimized.

Show comment
Hide comment
@deneuxa

deneuxa May 20, 2013

Thanks ! :)

deneuxa commented May 20, 2013

Thanks ! :)

@albrow

This comment has been minimized.

Show comment
Hide comment
@albrow

albrow May 23, 2013

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.

albrow commented May 23, 2013

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.

@mastfish

This comment has been minimized.

Show comment
Hide comment
@mastfish

mastfish Jun 4, 2013

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.

mastfish commented Jun 4, 2013

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.

@rusllonrails

This comment has been minimized.

Show comment
Hide comment

Thanks )

@abkreno

This comment has been minimized.

Show comment
Hide comment
@abkreno

abkreno Jul 30, 2015

Thanks 👍

abkreno commented Jul 30, 2015

Thanks 👍

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