Skip to content

jakehow/validates_not_overlapping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ValidatesNotOverlapping

This plugin is meant to simplify models related to the reservation of physical resources.

Example

The plugin provides one class validation method for your ActiveRecord models:

validates_not_overlapping(start_attribute, finish_attribute, options)

Valid options:

  • :message – lets you specify a custom error message

  • :allow_equal_endpoints – lets you set whether endpoints of 2 models can be equal (default value: false)

  • :scope – scope the comparison to an attribute or method when passed a symbol, also can take a string (with delayed interpolation) for more complicated scopes

class CarRental < ActiveRecord::Base validates_not_overlapping :start, :finish, :scope => :car_id, # could also be expressed as: :scope => ‘`car_rentals`.car_id = #{car_id}’ :message => ‘has already been rented during this time.’ end

Copyright © 2008 Jake Howerton, released under the MIT license

About

ActiveRecord plugin helps to deal with reserving physical resources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages