Skip to content

Instantly share code, notes, and snippets.

@messiahxu
Created November 10, 2014 13:37
Show Gist options
  • Save messiahxu/2c7253cb09379f479b66 to your computer and use it in GitHub Desktop.
Save messiahxu/2c7253cb09379f479b66 to your computer and use it in GitHub Desktop.
rails 4 user update_without_password
class User < ActiveRecord::Base
.....
# password section
has_secure_password
validates :password, length: { in: 6..30 }, if:->{password.present?}
.......
def update_without_password(params = {})
params.delete(:password)
params.delete(:password_confirmation)
result = self.update_attributes(params)
end
.......
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment