Simulating a foreign key constraint in ActiveRecord (Ruby on Rails)
It wasn't entirely obvious (to me) how to achieve this in an ActiveRecord model - you need *both* of the following two lines:
validates_presence_of :category, :message => " must be specified" validates_associated :category
Hope this helps someone.