Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Last active July 1, 2019 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blairanderson/c7919eaa507e47b695ccecb26ce37399 to your computer and use it in GitHub Desktop.
Save blairanderson/c7919eaa507e47b695ccecb26ce37399 to your computer and use it in GitHub Desktop.
RAILS email input with multiple=true
# 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