Skip to content

Instantly share code, notes, and snippets.

@hieu-v
Last active March 22, 2020 08:10
Show Gist options
  • Save hieu-v/b5a434223897695ce0789efc11a1eb97 to your computer and use it in GitHub Desktop.
Save hieu-v/b5a434223897695ce0789efc11a1eb97 to your computer and use it in GitHub Desktop.
Gem Devise tips

Change email without confirmation

@user = User.find_by_email('bob@site.com')
@user.email = 'dead@site.com'
@user.skip_reconfirmation!
@user.save!

Require password_confirmation when create new user

class User
  validates :password_confirmation, presence: true, on: :create
end

Valid password

user.valid_password?(params[:user][:password])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment