Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 933 Bytes

README.rdoc

File metadata and controls

24 lines (15 loc) · 933 Bytes

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