Project

General

Profile

Trying to add a value to the TimeEntry Model

Added by Shaun Gilroy almost 15 years ago

I'm almost too embarrassed to ask this, but I'm really new to plugin writing.

I'm trying to get a column in time_entries to get a custom value regardless of where you enter time from and its just not happening. I'm trying to get this simple case working before I try anything more complicated.

This is the gist of what I'm trying to do... This is a lib I'm requiring from the init.rb

---
require_dependency 'time_entry'

module AssignrateTimeEntryPatch
def self.included(base) # :nodoc:
base.extend(ClassMethods)

base.send(:include, InstanceMethods)
base.class_eval do
end
end
module ClassMethods
end
module InstanceMethods
def before_save
self.activity_rates_hourly_rate = 12
end
end
end

TimeEntry.send(:include, AssignrateTimeEntryPatch)
---

So... I'm not sure why before_save isn't making the values TimeEntry.activity_rates_hourly_rate isn't making it to the database with a value of 12.

I've had no troubles making plugins that introduce new functions to work, but I can't get anything working when I try to add to the existing Model.


Replies (1)

RE: Trying to add a value to the TimeEntry Model - Added by Shaun Gilroy almost 15 years ago

Never mind. I've discovered that my underlying strategy was ill-advised. I'll be pursuing a different tactic.

    (1-1/1)