Rails: Parsing iCal calendar on a password-protected WebDAV server

It took me a little while, but I finally got this working. You’ll need the iCalendar plugin.

require 'icalendar' 
def view_ical
    request = Net::HTTP::Get.new('/calendars/calendar.ics') 
   response = Net::HTTP.start('webdav.site.com') {|http| 
     request.basic_auth 'username', 'password' 
     response = http.request(request) 
   } 
   calendar_text = response.body
   calendars = Icalendar.parse(calendar_text) 
   calendar = calendars.first
end