module Users class RegistrationsController < Devise::RegistrationsController before_action do authorize resource, nil, policy_class: UserRegistrationPolicy end def create build_resource(sign_up_params) ActiveRecord::Base.transaction do resource.save yield resource if block_given? if resource.persisted? create_account_for(resource) expire_data_after_sign_in! render_message else clean_up_passwords resource set_minimum_password_length respond_with resource end end end def render_message msg = <<~HTML