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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -