Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 831
Obromios Avatar asked Aug 19 '16 22:08

Obromios


2 Answers

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 %>
like image 199
Eliot Sykes Avatar answered Nov 09 '22 08:11

Eliot Sykes


Just add

  <%= f.error :base %>

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

like image 22
Obromios Avatar answered Nov 09 '22 09:11

Obromios