Browse the Ruby on Rails Community.

You are here: Browse Railsplugins First Class Dates

First Class Dates

Installation

first_class_dates is Rails plugin. Install as normal with a plugin:

{{{ > script/plugin install https://opensource.thinkrelevance.com/svn/first_class_dates/tags/stable/first_class_dates }}}

Dependencies first_class_dates's tests rely on test/spec

{{{ > sudo gem install test-spec }}}

Overview

When it comes to Rails validation, dates are second-class citizens. Invalid dates (such as Feb 30) are allowed by Rails helpers, but instead of triggering validation errors they raise an {{{ActiveRecord::MultiparameterAssignmentError}}}.

I (Stu) think that such invalid dates should be treated as validation errors, for consistency with, well, every other kind of validation in Rails.

If you include this plugin, invalid dates will be reported as validation errors instead.

There are no configuration options because I haven't needed them yet.

Usage

Simply add the plugin. That's it.

Other Approaches ==

Shinya Kasatani’s [http://wiki.rubyonrails.org/rails/pages/Validates+Multiparameter+Assignments|Validates Multiparameter Assignments] plugin lets you turn on a similar validation per model class.

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly

Users


See all details


Membership

+ Join this railsplugin

Record Maintainer

'None'