As I am reading the rails 3 way I wanted to make a small app that will help me learn along with the book. I am thinking of making a simple timesheet application in rails, however, I can’t figure out where to start as far as calendar functionality goes. This is what I have so far.
User has_many Timesheets
Timesheet belongs_to user
Timesheet will have date:datetime, hours:datetime and comments:string attributes.
how can I map a whole month to the timesheet?
For example.
if the user wants to fill timesheet for 06/01/2011 - 06/07/2011 will he have seven rows in the Timesheet table?
I would like someone to explain a brief architecture of ActiveRecord for this.
I would at least start out with something like this:
Timesheetwill have auser_id:integerattribute.WorkDaywill haveday:date,hours:integer,comment:text, andtimesheet_id:integerattributes.Then you can create timesheets with any collection of individual workdays you wish.
The form for a WorkDay could look something like this:
This will allow you to create a new WorkDay with all of its attributes and attach it to any existing Timesheet.
Note: This will look for a
namemethod in Timesheet, which you could implement like this, for example: