My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Links

MultiFieldDate

Description

This is a Ruby on Rails plugin for use with tables/models that need to allow incomplete dates (e.g., just the year and month or just the month and day). Requires that the table have four fields: year, month, day, and full date. When the year, month, and day fields are present, the full date field is updated.

There are two ways to use this plugin:

  • acts_as_multi_field_date
  • multi_field_date

acts_as_multi_field_date only allows one date_field per model. e.g.,

class Birth < ActiveRecord::Base
  acts_as_multi_field_date :date_field => 'birth_date'
  #assumes year, month, and day fields are 'year', 'month', and 'day' by default.
  #can be changed: 
  # acts_as_multi_field_date :date_field => 'birth_date', :day_field => 'bday'
end

multi_field_date, on the other hand, allows multiple dates in a model, e.g.,

class Person < ActiveRecord::Base
  multi_field_date :birth, :date_field => 'birth_date', :year_field => 'birth_year',
    :month_field => 'birth_month', :day_field => 'birth_day'
  multi_field_date :death, :date_field => 'death_date', :year_field => 'death_year',
    :month_field => 'death_month', :day_field => 'death_day'
end

It also includes a helper method for displaying a partially completed date, and some helpers for generating arrays for HTML select menus. Includes rather extensive unit test coverage (requires SQLite3).

Installation

script/plugin install http://rails-multifielddate-plugin.googlecode.com/svn/plugins/multi_field_date

Then run rake doc:plugins to generate RDoc documentation.

See also: README

Powered by Google Project Hosting