Created
March 5, 2021 16:16
-
-
Save wking-io/7a9bbac0916d94ac8595c698ecf447f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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