Advertisement
saasbook

conditional_validation_example_2.rb

Jan 10th, 2012
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.25 KB | None | 0 0
  1. class Movie < ActiveRecord::Base
  2.   RATINGS = %w[G PG PG-13 R NC-17]
  3.   validates_inclusion_of :rating, :in => RATINGS,
  4.     :if => :after_ratings_adopted?
  5.  
  6.   def after_ratings_adopted?(movie)
  7.     self.release_date >= Date.parse('1-Nov-1968')
  8.   end
  9.  
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement