-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #30: Patch TimeEntry to relate TogglMapping.
When a TimeEntry is deleted, related TogglMapping records are also deleted.
- Loading branch information
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ | |
{ controller: 't2r', action: 'index' }, | ||
caption: 'Toggl' | ||
end | ||
|
||
# Patches. | ||
require 'patches/time_entry.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Patch Redmine's TimeEntry model. | ||
# | ||
# When a time entry is deleted, all related Toggl mappings should be deleted. | ||
module Toggl2Redmine | ||
module TimeEntryPatch | ||
def self.included(base) | ||
base.class_eval do | ||
unloadable # To not unload in development? | ||
has_many :toggl_mappings, dependent: :destroy | ||
end | ||
end | ||
end | ||
end | ||
|
||
TimeEntry.send(:include, Toggl2Redmine::TimeEntryPatch) |