Skip to content

Instantly share code, notes, and snippets.

@wking-io
Created March 5, 2021 16:16
Show Gist options
  • Save wking-io/7a9bbac0916d94ac8595c698ecf447f7 to your computer and use it in GitHub Desktop.
Save wking-io/7a9bbac0916d94ac8595c698ecf447f7 to your computer and use it in GitHub Desktop.
## Params
# {
# "user" => {
# "owned_accounts_attributes" => { "0" => { "name" => "[FILTERED]" } },
# "name"=>"[FILTERED]",
# "email"=>"[FILTERED]",
# "password"=>"[FILTERED]",
# "time_zone"=>"Central Time (US & Canada)",
# "terms_of_service"=>"0"
# }
# }
def sign_up_params
add_subdomain_from_account_name
devise_parameter_sanitizer.sanitize(:sign_up)
end
def add_subdomain_from_account_name()
account_params = params[:user][:owned_accounts_attributes].values.first
if account_params.key?(:name) && ! account_params[:name].empty?
account_params[:subdomain] = account_params[:name].gsub(/\s+/, "").downcase
end
params[:user][:owned_accounts_attributes]['0'] = account_params
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment