Simple client side validation for Rails that keeps validation in the models
Ruby HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app
config
lib
spec
vendor
.DS_Store
.gitignore
.ruby-version
.travis.yml
Gemfile
README.rdoc Add travis shield Oct 12, 2015
RELEASE.md
Rakefile
green_light.gemspec

README.rdoc

green_light Build Status

Provides client side validation, with the help of the jquery validation plugin. Keeping validation in the model, where it belongs.

Installation

Add green_light to your Gemfile and run the bundle install command.

gem 'green_light'

Usage

Include the JQuery validation plugin in your app/assets/javascripts/application.js file:-

//= require jquery.validate

Since the validation rules are creating dynmically they need to be included in the header of your layout file:-

<%= javascript_include_tag "green_light" %>

Add the green_light class to the forms that you wish to have client side validation:-

<%= form_for(@model, :html => { :class => 'green_light' }) do |f| %>

And finally, add some validations to your models!

Currently Supports these validations

validates_presence_of
validates_length_of
validates_format_of
validates_uniqueness_of
validates_numericality_of

For validations that are not yet supported, the gem will degrade gracefully to the standard Rails server-side validation.

Legacy Rails 3 Support

For Rails 3 support use the older version (0.0.3) of green_light

Requirements

JQuery is require for the jquery validation plugin. Be sure to include this in your application.js file:-

//= require jquery

Running the Tests

bundle install
bundle exec rspec spec