Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
Last active May 26, 2020 10:15
Show Gist options
  • Select an option

  • Save pixeltrix/b408f9be9f7aaaebc4f2c7d6088cd039 to your computer and use it in GitHub Desktop.

Select an option

Save pixeltrix/b408f9be9f7aaaebc4f2c7d6088cd039 to your computer and use it in GitHub Desktop.
Example of a 'service' object
class PasswordSetter
def initialize user
@user = user
end
def set_password password, responder
@user.password = password
if @user.valid?
@user.save!
responder.render_success
else
errors = @user.errors.messages.to_json
responder.render_errors errors
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment