Advertisement
saasbook

validating_associations.rb

Aug 15th, 2013
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.27 KB | None | 0 0
  1. class Review < ActiveRecord::Base
  2.   # review is valid only if it's associated with a movie:
  3.   validates :movie_id, :presence => true
  4.   # can ALSO require that the referenced movie itself be valid
  5.   #  in order for the review to be valid:
  6.   validates_associated :movie
  7. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement