Time Sheet

Allows for threaded time entries to be added to multiple and different models.

Based off of the acts_as_commentable_with_threading gem.

Requirements

This gem is for Rails 3 and later versions only.

This gem depends on CollectiveIdea's Awesome Nested Set gem. It is installed if not already present when you install this gem.

You can find the gem on GitHub at collectiveidea/awesome_nested_set

Install

In your Gemfile, add:

gem 'time_sheet', :git => 'git://github.com/zflat/time_sheet.git'

and run bundle install.

Migrations

  • To install from scratch:

    rails generate time_sheet_migration
    

    This will generate the migration script necessary for the table

If the generators fail, you can just as easily create the migrations by hand. See the templates in the generators under lib/generators.

Usage

class Project < ActiveRecord::Base
  has_time_sheet
end
  • Add a work entry to a model instance, for example a Project:

    @proj = Project.find(params[:id])
    @user_who_worked = @current_user
    @time_entry = TimeEntry.build_from( @proj, @user_who_worked.id, "Pushed some paper from here to there." )
    
  • To make a newly created time entry into a child/reply of another time entry:

    time_entry.move_to_child_of(the_desired_parent_entry)
    
  • To retrieve all time entries for a project, including child entries:

    @all_time_entries = @proj.time_entry_threads
    
    # alternatively use the alias
    @all_time_entries = @proj.time_entries        
    
  • To retrieve only the root entries without their child entries:

    @root_time_entries = @proj.root_time_entries
    
  • To check if a project has children:

    @proj.has_children?
    
  • To verify the number of children a time entry has:

    @time_entry.children.size
    
  • To retrieve an entrie's children:

    @time_entry.children
    

To Test

    rspec spec

Credits

This gem originated from acts_as_commentable_with_threading

And in turn...

  • Xelipe - Because acts_as_commentable was heavily influenced by Acts As Taggable.

More