0
確認被觸發,並按照我所傳遞的記錄的屬性(即required(:title).filled
)按預期工作,但不適用於嵌套模型的屬性(即required(:name).filled
的artist
)。如何使用改革+幹驗證驗證嵌套屬性?
class AlbumForm < Reform::Form
property :title
validation do
required(:title).filled
end
property :artist do
property :name
validation do
required(:name).filled
end
end
end
(摘錄自http://trailblazer.to/gems/reform拍攝)
我希望Albumform.new(album).valid?
到如果album.artist.name == nil
但它沒有返回false。我在這裏錯過了什麼?這怎麼能實現?
使用:
- 軌4.2.7.1
- 改革護欄0.1.7
- 改革2.2.2
- 幹驗證0.10.3