ruby - Validating a blank field Rails Model -
this may basic cannot find definitive answer anywhere. have set contact form within app , have put in hidden field when completed disables submit button jquery. attempt @ stopping automated spam..
can add validations in model?
validates :ghost, :presence => false
looking @ docs invalid? want form fail if field filled in. not sure how go one
edit
so have read possibly use
validates_exclusion_of :ghost, :on => :create
though still failing dont think passing correct arguments.
:presence => false
means disable presence validator.
you need write own absence validation (though in rails 4.0 such validation exists, absence: true
).
validate :ghost_is_absent def ghost_is_absent errors.add :ghost if ghost.present? end
Comments
Post a Comment