Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 28 lines (21 sloc) 1.202 kB
5d22576 @aka47 initial commit
aka47 authored
1 Simple plugin to extract validations from active-record to use them with jquery.validate and jquery.metadata
2
3 Description
4 =====
5 It adds the validation rules with custom error messages into the form markup, query.validate (with jquery.metadata which is needed to read the markup)
6 reads them automaticly out.
7 It requires the validation_reflection plugin (http://rubyforge.org/projects/valirefl/)
8
9 Setup
10 =====
11 script/plugin install git://github.com/jovoto/
12
13 We are using it together with formtastic, that is what you need to add to formtastic:
14
15 def input(method, options = {})
16 ...
17 options[:input_html] ||= {}
18 if @object && @object.class.respond_to?(:reflect_on_validations_for) && self.respond_to?(:build_validations)
19 options[:input_html][:class] = [build_validations(@object, method, options), options[:input_html][:class]].join(" ")
20 end
21
22 It extracts :validates_presence_of, :validates_acceptance_of and validates_length_of validation rules
23 It also adds :validates_uniqueness_of, to get this working you need to add an check method to the responding controller, this method has to implement
24 the uniqueness validation
25
26 [Tim Aßmann](http://devo.to)
27 tassmann@jovoto.com
Something went wrong with that request. Please try again.