Note that there are some explanatory texts on larger screens.

plurals
  1. POVpim::Vcard - Parsing vcard 2.1
    primarykey
    data
    text
    <p>My code must parse Vcard 2.1 format. I am using vpim(there are no other libs)</p> <p>When I run <code>Vpim::Vcard.decode(data)</code> I get error:</p> <pre><code>undefined method `each' for #&lt;String:0x0000000928e778&gt; </code></pre> <p>StackTrace:</p> <pre><code> NoMethodError (undefined method `each' for #&lt;String:0x0000000928e778&gt;): 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' </code></pre> <p>I tryed to run <code>gem install vcard</code> and to require 'vcard' directry(config.gem does not include this file after vpim gem) after RailsApp initialization.(<code>config.gem 'vpim'</code> is included in environment.rb) By this way I get another error:</p> <p><code>;=D0=9D=D0=B0=D0=B4=D1=80=D0=B0=20=D0=B1=D0=B0=D0=BD=D0=BA=20=D0=BE=D0=BB=</code></p> <p>(Exception class is <code>Vpim::InvalidEncodingError</code>)</p> <p>Vcard code I try parse:</p> <pre><code>BEGIN:VCARD VERSION:2.1 REV:20090710T151929Z TEL;CELL:80954130722 X-CLASS:private END:VCARD </code></pre> <p>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.</p> <p>StackTrace:</p> <pre><code> 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' </code></pre> <p>app/models/event.rb:71 :</p> <pre><code>vcard = Vpim::Vcard.decode(contact.text) </code></pre> <p>Here is axample from irb:</p> <pre><code>95-25-164-74:~ smix$ irb ruby-1.9.2-rc2 &gt; str = &lt;&lt;EOS ruby-1.9.2-rc2"&gt; BEGIN:VCARD ruby-1.9.2-rc2"&gt; VERSION:2.1 ruby-1.9.2-rc2"&gt; REV:20090710T151929Z ruby-1.9.2-rc2"&gt; TEL;CELL:80954130722 ruby-1.9.2-rc2"&gt; X-CLASS:private ruby-1.9.2-rc2"&gt; END:VCARD ruby-1.9.2-rc2"&gt; EOS =&gt; "BEGIN:VCARD\nVERSION:2.1\nREV:20090710T151929Z\nTEL;CELL:80954130722\nX-CLASS:private\nEND:VCARD\n" ruby-1.9.2-rc2 &gt; require 'vpim' =&gt; true ruby-1.9.2-rc2 &gt; Vpim::Vcard.decode str NoMethodError: undefined method `each' for #&lt;String:0x000001010e0428&gt; 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 `&lt;main&gt;' ruby-1.9.2-rc2 &gt; </code></pre> <p>How is it possible to parse Vcard 2.1 in rails?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload