Dennis Hackethal
Dennis Hackethal

Reputation: 14295

Show no errors on validation

Plain and simple:

How do I validate fields but don't show any errors for those? I need to validate nested attributes and validate them, but not show any error messages.

Upvotes: 1

Views: 94

Answers (1)

MurifoX
MurifoX

Reputation: 15109

If i understand you correctly, just go to your view where the code for printing the errors are, and remove it.

If created by scaffold, they are located inside the forms of your models, (_form.html.erb). Remove the code where it loops the error messages from the model.

UPDATE

You can too, put a after_validation filter on your model, that clears the errors array.

def model
  after_validate :clear_errors_array

  def clear_errors_array
    @model.errors.clear
  end

Upvotes: 1

Related Questions