binarylogic / boolean_datetime_attribute

Let's datetime attributes act as booleans

This URL has Read+Write access

binarylogic (author)
Thu Sep 11 09:38:09 -0700 2008
commit  9c022f2b5e5ff129ef0442328b38de0bf614716a
tree    01f9420638dda59c4c8f594ae4a93de5e4f2bfef
name age message
file MIT-LICENSE Loading commit data...
file README.mdown
file init.rb
directory lib/
README.mdown

Boolean datetime attribute

What is boolean attribute?

This plugin allows you to replace boolean columns with datetime columns. For example, you have a User model with the "inactive" boolean column. Why not make it more informative and change that column to "inactive_at"? Now you know when the user was marked inactive. This plugin allows you to do that and still get all of the methods that you would have for a boolean column. It's transparent, you can treat it as a boolean, but it will store it as a date.

How it works

class User < ActiveRecord::Base
    boolean_datetime_attribute :inactive_at
end

Copyright (c) 2007 Ben Johnson of Binary Logic, released under the MIT license