How can I upload and parse a vcard using ruby on rails?
-
30-09-2019 - |
Question
I would like to be able to upload a vcard and have it parsed into my application's Model.
I am thinking that Paperclip would be a way to upload, but I have no idea how to do the parse.
I did a search on google, the only library that seems related is vpim, with mixed commentary.
Wanted to see what brilliant ideas might be out there to solve this...thanks.
Solution 2
solved it using vpim
OTHER TIPS
vpim is a helpful gem for making and importing vCards here is how to use this...
gem 'vpim', '~> 13.11.11' #include this in your gemfile
in your controller decode vcard
@vcard = Vpim::Vcard.decode(params[:import_file].read)
@contact.title = @vcard.title
@contact.email = @vcard.email
@contact.first_name = @vcard.name.given
@contact.last_name = @vcard.name.family
@contact.phone = @vcard.telephones[0]
@contact.fax = @vcard.telephones[1]
@contact.address.street1 = @vcard.address.street
@contact.address.city = @vcard.address.locality
@contact.address.state = @vcard.address.region
@contact.address.zip = @vcard.address.postalcode
@contact.company_name = @vcard.org.fetch(0)
Another gem u could use is vcardigan
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow