This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon () is private.
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon () is public.
Description:
Allows an ActiveRecord model to repeat based on conditions. Just like a calendar event repeats in a calendar.
This plugin makes repeating a record easy. For example, if you have a calendar where events can be repeated this will give you everything you need to do that. This is not limited to calendar events, it can be applied to anything with a date.
How it works
It’s simple actually, most of my inspiration came from Apple’s iCal. Let’s take the calendar event example. Your event must have the following database columns: (any of these can be renamed, the new names must be passed in as options)
parent_id (integer, used for acts_astree)
startsat (date or datetime)
endsat (optional, date or datetime)
repeat (boolean)
repeatdetails (text, serialized hash containing all of the details)
stop_repeatingat (date or datetime)
You want to create an event that repeats weekly. You have the first event where you specify the repeat details. Through the aftersave hook and using the repeat details children of that event, with the same details, are created. That’s it. If an even has a parent then you know its a product of an event being repeated.
Usage
class Event < AcitveRecord::Base
acts_as_repeatable # options:
# :starts_at_column => "name of column that contains the start time",
# :ends_at_column => "name of column that contains the end time"
end
Todo
Don’t clear out children on aftersave. I don’t like deleting and re-adding records unless that’s what I am explicitly doing.
Finish monthly and yearly repeating
Create rake task to create migration for adding additional fields for a specific model. If a model already has some fields raise an error, if not create the migration.
Copyright (c) 2007 Ben Johnson of Binary Logic, released under the MIT license