3
我有一個自定義的驗證方法:傳遞字段名作爲參數傳遞給自定義的驗證方法的Rails 4
def my_custom_validation
errors.add(specific_field, "error message") if specific_field.delete_if { |i| i.blank? }.blank?
end
的目標是禁止含有[""]
穿過驗證參數,但我需要調用此方法,如:
validate :my_custom_validation #and somehow pass here my field names
例如:
validate :my_custom_validation(:industry)