Last active
July 1, 2019 22:17
-
-
Save blairanderson/c7919eaa507e47b695ccecb26ce37399 to your computer and use it in GitHub Desktop.
RAILS email input with multiple=true
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
# simple_form sends params inside an array | |
# ["first@email.com,second@email.com"] | |
def email_cc_list=(list) | |
write_attribute(:email_cc_list, | |
Array.wrap(list).first.split(",").uniq.join(",") | |
) | |
end | |
# is it possible the array ever holds more than 1 value? | |
# Array.wrap(list).map { |l| l.split(",") }.flatten.uniq.join(",") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment