title: rails : displaying error messages on a form
body: <p>i have a 'modif' action, activated by a link, that loads data from my database, then displays a form via a 'modif' view. The form is linked to a @newaut.
  On this form, a link leads to a 'modifvalid' action. It operates some tests on the data entered and may return an error message.
  In case of an error, if i redirect to 'modif' action to display the error, my data come to their original values, my changes on the form are lost, and the error is displayed.
  So, i render my 'modif view. But @newaut doesn't exist anymore, so i must reload it with the params data. The result is ok.
  Is there a way to just display the error message without reloading all the data entered on the form.
  Thanks.</p>
  
  <pre><code>    def modif
        @zgtitre="Modification d'un Auteur"
        @newaut=Auteur.find(params[:id])
      end
  
      def modifvalid
        @newaut=Auteur.find(params[:auteur][:id])
        @newaut[:autabr]= params[:auteur][:autabr].upcase
        @newaut[:autnom]= params[:auteur][:autnom]
        inderr=0
        flash[:meserr]=""
        if ..... then
          flash[:meserr]="xxxxx"
          inderr=1
        end
        if inderr==1 then
          @zgtitre="Modification d'un Auteur après erreur"
          render :modif
          return
        else
          @newaut.save
          redirect_to lister_les_auteurs_path
        end
      end
  
      &lt;%= form_for @newaut, url: {action: "modifvalid"}, method: :post do |f| %&gt;
      &lt;%= f.hidden_field :id %&gt;
      &lt;div class="field"&gt;
        &lt;%= f.label :Nom %&gt;&lt;br&gt;
        &lt;%= f.text_field :autnom %&gt;
        &lt;%= flash[:meserr] %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
        &lt;%= f.label :Nom_court %&gt;&lt;br&gt;
        &lt;%= f.text_field :autabr %&gt;
      &lt;/div&gt;
      &lt;div class="commandes"&gt;
        &lt;%= f.submit "Valider", class: "commandes_liens"%&gt; 
        &lt;%=link_to "Abandonner", lister_les_auteurs_path, class: "commandes_liens" %&gt;
      &lt;/div&gt;
      &lt;% end %&gt;
  </code></pre>