# Publishing an ical calendar?

**URL:** <https://www.ruby-forum.com/t/publishing-an-ical-calendar/115365>\
**Category:** Rails\
**Created:** [September 24, 2007, 2:32pm UTC](https://www.ruby-forum.com/t/publishing-an-ical-calendar/115365 "2007-09-24T14:32:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 24, 2007, 2:32pm UTC](https://www.ruby-forum.com/t/publishing-an-ical-calendar/115365/1 "2007-09-24T14:32:07Z")

</div>

I have a table of events and want to create an action in one of my  
controllers to allow people to subscribe to an ical so these events will  
show up in their calendar. Any ideas on how I would do this? I couldnt  
find anything on google.

Thanks.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 24, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/publishing-an-ical-calendar/115365/2 "2007-09-24T15:06:15Z")

</div>

Ben J. wrote:

> I have a table of events and want to create an action in one of my  
> controllers to allow people to subscribe to an ical so these events will  
> show up in their calendar. Any ideas on how I would do this? I couldnt  
> find anything on google.
> 
> Thanks.

I’ve done this before. you need to be generating iCalendar (ex  
vcalendar) files which is a reasonably simple text based format, defined  
by [http://www.ietf.org/rfc/rfc2445.txt](http://www.ietf.org/rfc/rfc2445.txt) (see the bottom of that document  
for some actual examples.

Fred

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 24, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/publishing-an-ical-calendar/115365/3 "2007-09-24T15:12:14Z")

</div>

On 24 Sep 2007, at 13:32, Ben J. wrote:

> I have a table of events and want to create an action in one of my  
> controllers to allow people to subscribe to an ical so these events  
> will show up in their calendar. Any ideas on how I would do this? I  
> couldnt find anything on google.

The icalendar gem can help with that:

[http://icalendar.rubyforge.org/](http://icalendar.rubyforge.org/)

I’m using it along these lines:

class EventsController \< ActionController::Base  
def index  
@events = Event.find(:all)

```
respond_to do |format|
  format.html

  format.ics do
    cal = Calendar.new
          @events.each do |event|
           cal_event = Event.new
           cal_event.start = event.starts_at
           cal_event.summary = 'My title'
           cal_event.description "My Description"
           cal.add_event(cal_event.to_ical)
         end
         render :text => cal.to_ical
       end
 end

```

end  
end

James.

–  
James S.  
Play: [http://james.anthropiccollective.org](http://james.anthropiccollective.org)  
Work: [Processing Greenbelt 2009 – James Stewart](http://jystewart.net/process/)
