-
Notifications
You must be signed in to change notification settings - Fork 17
Home
Work-in-progress documentation. Feel fre to edit at will.
In an ideal world, this plugin works out of the box. There are a few things to be aware of, though. Here you go:
The plugin allows configuration particular to the adapter you’re using. Refer to the documentation for the individual adapters:
Because your database is the only place where you can ask for uniqueness, this feature requires a controller callback. If you run a version of Rails older than 2.3, you will have to run the following command:
ruby script/generate live_validator
That’s because plugins couldn’t do controllers very easily back then. This adds a controller in your app/ folder, and adds some stuff to routes.rb.
The regexp provided in your model will be displayed as-is to the javascripts. The plugin does not do anything to try to cope with differences between Ruby and JS regular expressions, so you can specify a JS specific regexp with the :live_validator
option. A semi-sensible example:
validates_format_of :foo, :with => /\A[a-z]\z/, :live_validator => "/^[a-z]$/"
The plugin will ask the I18n library for validation messages. If you specify :message
in your validation, this message will be used. Interpolating {model}
is supported (such as :message => "is not as {model} as you might think"
). Other I18n interpolations such as {{value}}
and {{attribute}}
is not supported.