adzap edited this page Oct 27, 2010 · 6 revisions

Upgrading from 2.x to 3.x

The plugin has been rewritten for Rails 3 to support the ActiveModel system. This has simplified things greatly. However there are a few changes are they are mainly just in the configuration.

Before anything make sure you have run the generator for the plugin to output the config initializer and I18n file.

$ rails generate validates_timeliness:install

Then see the config/initializers/validates_timeliness.rb file.


The plugin parser is now optional and is turned off by default. To turn it on you need to change the option in the config.

# in the setup block
config.use_plugin_parser = true

For convenience you can use the setup block to configure the parser as well. See the initializer for the examples.

The parser has now been extracted from this plugin and made into it's own gem called timeliness. You can use it for your own parsing needs apart from the plugin. Why? Well, check out the readme and see the benefits.

Error messages for :between option

The between error message has been removed in favour of using the :on_or_before or :on_or_after message, depending on whether the upper or lower bound fails validation. This change makes the plugin behave similar to the validates_length_of method, which uses the :too_long and :too_short error messages. The main reason for the change is that using a range in the error message just makes it too long and difficult read.

RSpec Matcher

The RSpec matcher has been removed. That method of spec the validation is just broken. You only end up copying and pasting the spec to model. You need to think about the values which should be allowed and the boundaries conditions. The matcher was only just checking you had added the validation at all. There other ways to do that. Besides the matcher code was crap.