Skip to content

Instantly share code, notes, and snippets.

@jeffrydegrande
Created November 23, 2010 19:42
Show Gist options
  • Save jeffrydegrande/712386 to your computer and use it in GitHub Desktop.
Save jeffrydegrande/712386 to your computer and use it in GitHub Desktop.
class Company < ActiveRecord::Base
def update_with_password(params={})
if params[:password].blank?
params.delete(:password)
params.delete(:password_confirmation) if params[:password_confirmation].blank?
end
update_attributes(params)
end
protected
def password_required?
!persisted? || password.present? || password_confirmation.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment