In a Proc I would like to validate that the provided statement returns true.
I tried the following:
validate :home, Proc.new { |c| c.home.kitchen.present? }
It does not work. It does not show validations errors when no kitchen is present.
Do I have to write it like this:
validate :home_kitchen_must_be_present
def home_kitchen_must_be_present
....
Or is there an available syntax to write it in one line? Thanks
Aucun commentaire:
Enregistrer un commentaire