-
Notifications
You must be signed in to change notification settings - Fork 1
Rails plugin to define a get and set method for dates using your own format
License
nigelramsay/stringify_date
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
StringifyDate
=============
Note: work in progress
Rails plugin to define a get and set method for dates using your own format.
Simple example
==============
class Person < ActiveRecord::Base
stringify_date :born_on, :format => :nz_format
end
Creates two methods called 'born_on_string' and 'born_on_string=' which will create, and parse date strings using the 'nz_format' as specified in ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS. This is often declared in your application.rb file.
Complex example
===============
class Person < ActiveRecord::Base
stringify_date :born_on, :format => :nz_format,
:stringified_name => 'birth_date', :required => true,
:required_message => 'is a mandatory field',
:invalid_message => 'should be in the format DD/MM/YYYY'
end
Error handling
==============
Creates an error message on the stringified field if:
- string does not parse (ie: invalid format supplied)
- required was true, but not supplied
TODO expand doco
Credits
=======
Ryan Bates for the original idea in his screencast "Making a plugin"
http://railscasts.com/episodes/33-making-a-plugin
Radio New Zealand who gave back to the community
http://www.radionz.co.nz
Able Technology for sponsoring further enhancements and testing
http://www.abletech.co.nz
Copyright (c) 2008 Nigel Ramsay, released under the MIT license
About
Rails plugin to define a get and set method for dates using your own format
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published