Allows for threaded time entries to be added to multiple and different models.
Based off of the acts_as_commentable_with_threading gem.
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
In your Gemfile, add:
gem 'time_sheet', :git => 'git://github.com/zflat/time_sheet.git'
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
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:
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:
To verify the number of children a time entry has:
To retrieve an entrie's children:
This gem originated from acts_as_commentable_with_threading
- xxx - For contributing the updates for Rails 3!
- Jack Dempsey - This plugin/gem is heavily influenced/liberally borrowed/stolen from acts_as_commentable.
And in turn...
- Xelipe - Because acts_as_commentable was heavily influenced by Acts As Taggable.