Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Calendar/Planner Application - Ruby on Rails

I am considering developing an application using Ruby on Rails that is a planner of sorts. I would like to give a user the ability to see a list of days, click a particular day, and then add things like: Meals, Expenses, Events, Todos, and Exercises. Really I am doing this for me and my growing family.

I am curious with how best to implement this. I can certainly see that Meals, Expenses, etc. need to belong_to :user but I am curious how to implement the belongs_to :day or something like that. Using the created_at or updated_at wouldn't necessarily allow me to provide views for future dates.

I can see how if I created a Days table and then added days through a time and date field that this would work but seems a little strange to ask people to create the actual days.

Or perhaps instead of that I could just create links to variables that search for @today, @tomorrow, but that would get messy.

I have browsed for gems/plugins but can't find one that works. Ideally a person would be able.

Anyone have any thoughts on how to implement something like this?

like image 607
bgadoci Avatar asked May 04 '10 18:05

bgadoci


2 Answers

There are a number of existing Rails calendars, such as http://github.com/elevation/event_calendar or http://github.com/topfunky/calendar%5Fhelper.

However, to answer your specific question about dates: I don't think there's any need to have Day as a model; simply give each event a start date and time, and an end date and time. Remember that Ruby makes it easy to search based on ranges, so "give me all of the events next week" is a cinch if each event has dates and times associated with it.

like image 82
Jacob Mattison Avatar answered Oct 30 '22 12:10

Jacob Mattison


I'll give it a shot...

Two tables; users and events. A user has many events and an event belongs to a user. Meal, Expenses, etc. are various types of Event. Within events, you can have fields for start and end time of the events. If needed (lets say an events last over multiple days), you could remove the day/time when events occurs into it's own table.

This way, when displaying the calendar for a user, you can find all the events for that date. If none are found, then display nothing.

What do you think?

like image 20
Pran Avatar answered Oct 30 '22 12:10

Pran