Obromios
Obromios

Reputation: 16373

Show base errors using simple_form

I have errors on the model as opposed to the model fields, so these are added to errors[:base]. In my simple form code I am using;

  <%= f.error_notification %>

This shows ordinary errors, but not the base errors. How do I view the base erros?

Upvotes: 13

Views: 8583

Answers (2)

Eliot Sykes
Eliot Sykes

Reputation: 10063

error_notification accepts a message option should you wish to override it using any base error messages.

<%= f.error_notification message: f.object.errors[:base].to_sentence %>

Upvotes: 12

Obromios
Obromios

Reputation: 16373

Just add

  <%= f.error :base %>

which will show the base errors at the top of the form.

Upvotes: 23

Related Questions