Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Backpack-like Calendar in Rails

What are the current best practices in the Rails world for displaying a calendar month view with event items bound to the days in the month (like in Backpack or Google Calendar, for example)?

I don't need anything like fancy stuff like drag and drop support. I'm just looking for code to let me get a list of events in my controller and somehow expose them as entries in a monthly calendar display view (maybe with class names on the HTML elements to allow me to display different types of events differently, or maybe to display events from multiple calendars).

There's the Dynamic Calendar Helper that was created a few years ago, which very well might still work just fine for me, but I'm just wondering if I should be looking at other plugins, too.

Other possibilities I've found so far:

  • A few possible contenders (judging from their descriptions) on GitHub
  • Joyent Connector, which is now open source, has calendar capabilities

So, can you point me in the right direction as to what folks are using to output monthly calendars with data these days?

like image 541
Gabe Hollombe Avatar asked Oct 29 '08 17:10

Gabe Hollombe


2 Answers

Here's a Rails plugin that can display multiple, overlapping events across calendar days.

http://github.com/elevation/event_calendar

Screenshot(s) at: http://dev.elevationblog.com/2009/7/23/event-calendar-rails-plugin

like image 130
Jeff Schuil Avatar answered Oct 21 '22 15:10

Jeff Schuil


Check out http://github.com/p8/table_builder/tree/master. It works more like form_for. It also doesn't require Event objects, just objects with a method that returns a date.

  <% calendar_for(@tasks, :year => @year, :month => @month) do |t| %>
    <%= t.head('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') %>
    <% t.day(:day_method => YOUR_DATE_METHOD) do |day, tasks| %>
      <%= day.day %><br />
      <% tasks.each do |task| %>
          <%= h(task.name) %><br />
        <% end %>
      <% end %>
    <% end %>
  <% end %>
like image 8
user60683 Avatar answered Oct 21 '22 15:10

user60683