refer to: https://stackoverflow.com/questions/31806431/rails-validation-knowing-which-field-is-invalid
product.valid? # => run validation callbacks, 这个方法一定要调用,否则不会展示下面的内容
product.errors.messages # => {:field1=>["cannot be nil"]}
refer to: https://stackoverflow.com/questions/31806431/rails-validation-knowing-which-field-is-invalid
product.valid? # => run validation callbacks, 这个方法一定要调用,否则不会展示下面的内容
product.errors.messages # => {:field1=>["cannot be nil"]}