Validates_associated will check the referenced object exists (ie a director with that id is in the Directors table). Validated_presence_of will make sure a value has been specified when you are creating a movie (you can't pass a null/nil value when creating a new movie). Between the two you should have what you need, but to be sure you could implement a before_create filter in the Movie model if you need to do fancy stuff.
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
validates_presence_of :relation_id & validates_associated :relation together | 1 | 151 | December 4, 2006 | |
How to validate presence of associated? | 4 | 308 | September 27, 2008 | |
validates :presence => association_name | 4 | 245 | November 23, 2011 | |
Validation the presence of an ActiveRecord belongs_to association should imply a valid associated object? | 4 | 181 | September 12, 2014 | |
validates_presence_of :parent_id stopping save | 7 | 159 | March 16, 2010 |