• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Ruby
  • Created over 13 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple client side validation for Rails that keeps validation in the models

green_light <img src=“https://travis-ci.org/overture8/green_light.svg?branch=master” alt=“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

More Repositories

1

jquery-rails3-uj

Demo app JQuery unobtrusive javascript in Rails 3 (UJS)
Ruby
20
star
2

Twitter-Blog-Demo

This is the demo code for the noupe.com twitter blog tutorial
Ruby
14
star
3

cerebral-react-falcor-example

Example of using Netflix's Falcor with Cerebral (React)
JavaScript
9
star
4

prototype-rails3-ujs

Demo Rails 3 UJS (unobtrusive javascript) application
7
star
5

theRailWorld

Source code for therailworld.com website.
JavaScript
7
star
6

practice-programming-resources

Some resources that are useful for practicing programming
5
star
7

nuts

Install fonts from fontsquirrel.com with ease
Ruby
4
star
8

freeagent-node

A node wrapper for the Freeagent API.
JavaScript
4
star
9

beer_mapping

A ruby wrapper for the beermapping.com site.
Ruby
3
star
10

mangoex

Elixir wrapper for the MangoPay API
Elixir
3
star
11

recipe_puppy

Ruby wrapper for the recipepuppy.com API
Ruby
3
star
12

meetee_promo

meetee.me site email sign up
Ruby
2
star
13

bc_walking

bc walking group
Ruby
2
star
14

test

test
2
star
15

test_cap_webhook

Test capistrano webhook
Ruby
2
star
16

testcache

Test caching subdomains
Ruby
2
star
17

saas_starter

Bootstrap payment functionality for getting started with a saas type app.
Ruby
2
star
18

simple_template

Very simple template language for text output.
Ruby
2
star
19

jruby_itext

Wee test of itext with JRuby
JavaScript
2
star
20

pivotal_proxy

Small Sinatra app that wraps the Pivotal Tracker XML API and converts the output to JSON.
Ruby
2
star
21

my-vimrc

My vim config
Vim Script
1
star
22

footstool

Simple, lightweight plugin for integrating couchdb into your Rails app
Ruby
1
star
23

meteor-wordcloud2

Meteor wrapper for wordcloud2.js lib
JavaScript
1
star
24

termail

Termail is a terminal based email client for Gmail, written in Ruby.
Ruby
1
star