Rails / validates_associatedはなんのためにあるのか?

勉強会で引っかかったので。。
バリデーションエラーが一個増えただけで、結局わからない。
ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Place < ActiveRecord::Base
has_many :shops
accepts_nested_attributes_for :shops
#これ↓
validates_associated :shops
end
class Shop < ActiveRecord::Base
belongs_to :place
validates :name, presence: true
validates :owner, presence: true
end
ある時
ない時
Shops is invalid
のエラーメッセージが追加されたけど、
これはなぜ必要なのだろう…
