Skip to content
/ mikado Public

Mikado wraps Activerecord validation conditions with a block.

Notifications You must be signed in to change notification settings

zirni/mikado

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mikado wraps Activerecord validation conditions with a block.

Mikado has been tested with ruby 1.8/1.9 and ActiveRecord >= 2.3.5

Example:

Instead of

  class Item < ActiveRecord::Base
    validates_presence_of :title, :if => :live?
  
    def live?
      true
    end  
  end

you can write like this

  class Item < ActiveRecord::Base
    include Mikado
    
    mikado :live? do
      validates_presence_of :title
    end
    
    def live?
      true
    end
  end
  
Currently mikado only supports the :if condition.
You can help yourself, just negate the condition value.

It supports all validations with name validates_*
It also supports the methods validate, validate_on_create,
validate_on_update and validate_each

About

Mikado wraps Activerecord validation conditions with a block.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages