Forum: Ruby on Rails VCard Upload Import

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5dd60445347fc3dec62474cc732fef0d?d=identicon&s=25 Kyle Mathews (Guest)
on 2006-01-12 23:35
(Received via mailing list)
I'm trying to add Vcard import functionality and I keep getting the
following using the code provided below. I'm using the VPIM library
to decode the vcards and add them to my database table. Can someone
help me out, or point me in a different direction for importing
VCards. Thanks.

Error:
cannot convert StringIO into String


Controller Code:
require 'vpim/vcard'

if request.post? and params[:import_file]
	cards = Vpim::Vcard.decode(File.open(params[:import_file]))
end
B554bcde846e4497eeffffc1399d3b09?d=identicon&s=25 Benjamin Stiglitz (Guest)
on 2006-01-12 23:56
(Received via mailing list)
> if request.post? and params[:import_file]
> 	cards = Vpim::Vcard.decode(File.open(params[:import_file]))
> end

Try File::read instead of File::open.

-Ben
5dd60445347fc3dec62474cc732fef0d?d=identicon&s=25 Kyle Mathews (Guest)
on 2006-01-13 00:05
(Received via mailing list)
I still get the same "cannot convert StringIO into String" error
message when I changed it to File.read

- Kyle
This topic is locked and can not be replied to.