Skip to content

Instantly share code, notes, and snippets.

@alexbrinkman
Last active July 22, 2016 18:19
Show Gist options
  • Save alexbrinkman/7ad4c41f781e862d04300cda8b5500d4 to your computer and use it in GitHub Desktop.
Save alexbrinkman/7ad4c41f781e862d04300cda8b5500d4 to your computer and use it in GitHub Desktop.
medium-open-closed-principle-within-devise-post-gist1
# POST /resource
def create
build_resource(sign_up_params)
resource.save
yield resource if block_given?
if resource.persisted?
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
set_minimum_password_length
respond_with resource
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment