Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1008101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:43:09+00:00 2026-05-16T08:43:09+00:00

My code must parse Vcard 2.1 format. I am using vpim(there are no other

  • 0

My code must parse Vcard 2.1 format.
I am using vpim(there are no other libs)

When I run Vpim::Vcard.decode(data) I get error:

undefined method `each' for #<String:0x0000000928e778>

StackTrace:

  NoMethodError (undefined method `each' for #<String:0x0000000928e778>):
    vpim (0.695) lib/vpim/rfc2425.rb:82:in `unfold'
    vpim (0.695) lib/vpim/rfc2425.rb:308:in `decode'
    vpim (0.695) lib/vpim/vcard.rb:692:in `decode'
    app/models/event.rb:71:in `block (2 levels) in parse_data'

I tryed to run gem install vcard and to require ‘vcard’ directry(config.gem does not include this file after vpim gem) after RailsApp initialization.(config.gem 'vpim' is included in environment.rb)
By this way I get another error:

;=D0=9D=D0=B0=D0=B4=D1=80=D0=B0=20=D0=B1=D0=B0=D0=BD=D0=BA=20=D0=BE=D0=BB=

(Exception class is Vpim::InvalidEncodingError)

Vcard code I try parse:

BEGIN:VCARD
VERSION:2.1
REV:20090710T151929Z
TEL;CELL:80954130722
X-CLASS:private
END:VCARD

It is interesting that second error is when I am decoding inside a Rails model.
When I try to decode directly from script/console (after installinv vcard gem and direct including ‘vcard’) I succesfuly get Vcard object.

StackTrace:

   Vpim::InvalidEncodingError (;=D0=9D=D0=B0=D0=B4=D1=80=D0=B0=20=D0=B1=D0=B0=D0=BD=D0=BA=20=D0=BE=D0=BB=):
     vcard (0.1.1) lib/vcard/field.rb:106:in `decode0'
     vcard (0.1.1) lib/vcard/field.rb:172:in `initialize'
     vcard (0.1.1) lib/vcard/field.rb:183:in `new'
     vcard (0.1.1) lib/vcard/field.rb:183:in `decode'
     vcard (0.1.1) lib/vcard/rfc2425.rb:308:in `block in decode'
     vcard (0.1.1) lib/vcard/rfc2425.rb:308:in `collect'
     vcard (0.1.1) lib/vcard/rfc2425.rb:308:in `decode'
     vcard (0.1.1) lib/vcard/vcard.rb:686:in `decode'
     app/models/event.rb:71:in `block (2 levels) in parse_data'

app/models/event.rb:71 :

vcard = Vpim::Vcard.decode(contact.text)

Here is axample from irb:

95-25-164-74:~ smix$ irb
ruby-1.9.2-rc2 > str = <<EOS
ruby-1.9.2-rc2"> BEGIN:VCARD
ruby-1.9.2-rc2"> VERSION:2.1
ruby-1.9.2-rc2"> REV:20090710T151929Z
ruby-1.9.2-rc2"> TEL;CELL:80954130722
ruby-1.9.2-rc2"> X-CLASS:private
ruby-1.9.2-rc2"> END:VCARD
ruby-1.9.2-rc2"> EOS
 => "BEGIN:VCARD\nVERSION:2.1\nREV:20090710T151929Z\nTEL;CELL:80954130722\nX-CLASS:private\nEND:VCARD\n" 
ruby-1.9.2-rc2 > require 'vpim'
 => true 
ruby-1.9.2-rc2 > Vpim::Vcard.decode str
NoMethodError: undefined method `each' for #<String:0x000001010e0428>
    from /Users/smix/.rvm/gems/ruby-1.9.2-rc2/gems/vpim-0.695/lib/vpim/rfc2425.rb:82:in `unfold'
    from /Users/smix/.rvm/gems/ruby-1.9.2-rc2/gems/vpim-0.695/lib/vpim/rfc2425.rb:308:in `decode'
    from /Users/smix/.rvm/gems/ruby-1.9.2-rc2/gems/vpim-0.695/lib/vpim/vcard.rb:692:in `decode'
    from (irb):10
    from /Users/smix/.rvm/rubies/ruby-1.9.2-rc2/bin/irb:17:in `<main>'
ruby-1.9.2-rc2 > 

How is it possible to parse Vcard 2.1 in rails?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:43:10+00:00Added an answer on May 16, 2026 at 8:43 am

    The problem is that String#each has been removed in Ruby 1.9.1. (Its functionality endures in String#each_line). To fix/work around this bug, do any of the following:

    • Run your rails app on Ruby 1.8.7.
    • You can edit the Vpim code to use String#each_line appropriately (and send the vpim authors a patch)
    • You can monkey-patch the String class by defining the each method

      class String
        alias_method :each, :each_line
      end
      
    • Switch to the vcard gem, which is taken from Vpim and which has Ruby 1.9.1 support.

    I recommend the 4th option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code to parse this date. It must show new date
My Java code must get string HH:MM from console and needs to operate with
I want to package a piece of code that absolutely must run on Java
you must have seen this piece of code somewhere else too,but obviously there's no
There must be an easier way or function to do this code here: #!/usr/bin/env
I need to parse DTDs using PHP and am hoping there's a simple library
ok, so there's basically 3 tasks this program must carry out: Parse a sentence
i have to write some code that initialize my data app. This must be
Is there an easy way to find parse errors in javascript code? Last week
Sometimes for testing/developing purposes we make some changes in the code that must be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.