Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing iCalendar with custom fields via Ruby/Rails rake task
    text
    copied!<p>I have a rake task setup that imports events from an <a href="http://www.trumba.com/calendars/smithsonian-events.ics" rel="nofollow">iCal file</a> using the iCalendar gem. The iCal also contains several custom fields in addition to the standard .ics fields. Is it possible to import those values as well?</p> <p>Lines like this in the iCal file I can handle with no problem:</p> <pre><code>DESCRIPTION:The lions and tigers are on exhibit. </code></pre> <p>The issue arises for lines like this:</p> <pre><code>X-TRUMBA-CUSTOMFIELD;NAME="Event Location";ID=10831;TYPE=SingleLine:Lower Level\, across from the Stars and Stripes Cafe </code></pre> <p>How would I refer to the custom "Event Location" field?</p> <p>Here's the code that I have thus far:</p> <pre><code>desc "Import events from Smithsonian" task :smithsonian =&gt; :environment do url = "http://www.trumba.com/calendars/smithsonian-events.ics" cals = Icalendar.parse(open(url)) cal = cals.first cal.events.each do |event| e = TempEvent.find_or_create_by_name( :name =&gt; event.summary.to_s, :description =&gt; event.description.to_s, :starts_at =&gt; event.dtstart.to_s, :ends_at =&gt; event.dtend.to_s, :tag_list =&gt; event.categories, :url =&gt; event.url, :facebook_url =&gt; "https://www.facebook.com/Smithsonian", :twitter_url =&gt; "https://twitter.com/smithsonian", :venue_name =&gt; "Smithsonian", :external_id =&gt; event.uid.to_s, :source =&gt; "Smithsonian iCal import", :published =&gt; true) end end </code></pre>
 

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