Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nigelramsay/stringify_date
Rails plugin to define a get and set method for dates using your own format
https://github.com/nigelramsay/stringify_date
Last synced: about 2 months ago
JSON representation
Rails plugin to define a get and set method for dates using your own format
- Host: GitHub
- URL: https://github.com/nigelramsay/stringify_date
- Owner: nigelramsay
- License: mit
- Created: 2008-08-13T08:36:38.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2008-08-13T09:19:32.000Z (over 16 years ago)
- Last Synced: 2023-04-11T17:06:10.411Z (over 1 year ago)
- Language: Ruby
- Homepage: http://www.abletech.co.nz/blog
- Size: 82 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
Awesome Lists containing this project
README
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
endCreates 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'
endError handling
==============Creates an error message on the stringified field if:
- string does not parse (ie: invalid format supplied)
- required was true, but not suppliedTODO expand doco
Credits
=======Ryan Bates for the original idea in his screencast "Making a plugin"
http://railscasts.com/episodes/33-making-a-pluginRadio New Zealand who gave back to the community
http://www.radionz.co.nzAble Technology for sponsoring further enhancements and testing
http://www.abletech.co.nzCopyright (c) 2008 Nigel Ramsay, released under the MIT license