New has_duration_field plugin
Posted November 1, 2009on:
Building on my previous post I created the has_duration_field plugin. As described, I wanted to represent a duration of time on a field in my model. Using the proxy_field plugin, I built the DurationField class and added it as the proxy for my columns tblk and tduty.
Before the has_duration_field plugin:
class Block < ActiveRecord::Base proxy_field [:tduty, :tblk], :as => DurationField end
I just implemented my DurationField class and threw it in my lib dir. As I did that I realized that really using proxy_field and the implementation of DurationField would make a neat little plugin.
With the plugin you can do this:
class Block < ActiveRecord::Base has_duration_field [:tduty, :tblk] end
The plugin just provides an implementation of the DurationField class for you and an easy way to make your column proxy to a DurationField.
./script/plugin install git://github.com/angelo0000/has_duration_field.git