-
Notifications
You must be signed in to change notification settings - Fork 1
Add ability to use datetime fields as boolean attributes to ActiveRecord models
License
daikini/event_attribute
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
EventAttribute ============== EventAttribute allows you to turn your date/datetime columns in to boolean attributes. Idea for this was taken from http://jamis.jamisbuck.org/articles/2005/12/14/two-tips-for-working-with-databases-in-rails Example ======= class Referral < ActiveRecord::Base event_attribute :applied_at, :attribute => 'pending', :nil_equals => true event_attribute :subscribed_on end referral = Referral.create(:applied_at => Time.now) referral.pending? # => false referral.subscribed? # => false referral.pending = true referral.applied_at # => nil referral.pending? # => true referral.subscribed = true referral.subscribed_on # => Time.now referral.subscribed? # => true # Dynamic finders are also added so that you can search on these boolean attributes. Referral.find_all_by_pending(true) # => [Referral objects] # or Referral.find_by_name_and_pending_and_subscribed('John Smith', false, true) # => Referral object Copyright (c) 2007 Jonathan Younger, released under the MIT license
About
Add ability to use datetime fields as boolean attributes to ActiveRecord models
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published