Simple form in rails doesn't display validation error messages

I have this simple_form in my app but it doesn't display any validation error messages:

<%= simple_form_for(@user) do |f| %>

     <%= f.error_notification %>

    <%= f.input :first_name, label: "Prénom" %>
    <%= f.input :last_name, label: "Nom" %>
    <%= f.input :email, label:"email" %>
    <%= f.input :telephone, label: "telephone"%>

    <p><%= f.label :birthdate, 'Date de naissance' %></p>
    <%= f.date_select :birthdate, {:include_blank => true, :default => nil, :use_month_names => ['Janv.','Fevr.', 'Mars', 'Avr.', 'Mai', 'Juin', 'Juil.', 'Août','Sept.', 'Oct.', 'Nov.', 'Déc.'], :order => [:day, :month, :year], :start_year => 1910, :end_year => 1995} %>
     <%= f.input :genre, label: "Sexe" %>
    <%= f.input :ranking, label:"Classement" %>
    <%= f.input :licence_number, label: "numéro de licence"%>
      <%= f.label :Photo%>
      <%= f.file_field :picture %>
    <%= f.label :licence %>
    <%= f.file_field :licencepicture %>
    <%= f.label :certificat %>
    <%= f.file_field :certifmedpicture %>
    <div id="validation"><%= f.submit %></div>
    <% end %>

Here are my validations in my user model

 validates :first_name, presence: { strict: true }, on: :update
 validates :last_name, presence: { strict: true }, on: :update

and you can have a look at my simple_form.en.yml:

"yes": 'Yes'
"no": 'No'
  text: 'required'
  mark: '*'
  # You can uncomment the line below if you need to overwrite the whole required html.
  # When using html, text and mark won't be used.
  # html: '<abbr title="required">*</abbr>'
  default_message: "Certains champs posent problèmes:"

My update method:

def update
  redirect_to user_path(current_user)

I don't get why the error notifications don't display as I have the proper f.error_notification in my view


As revealed in your comments, your controller doesn't check for a successful save and just blindly redirects to the user page. I didn't see any native functionality from simple_form that does this for you. You need to check for this successful save and re-render the edit form on failure so it can show those errors in f.error_notification:

def update
  if @user.update(user_params)
    redirect_to user_path(current_user)
    render 'edit'

Need Your Help

Form submit in webforms

I have got two buttons, which both submit a form in

Canvas Colour Match Range

javascript canvas

My current code scans canvas for a colour then removes it from the canvas and moves onto next pixel. What I would like to achieve is the intensity of the colours search. So we find similar colours ...