title: Puts out validations to html in rails
body: <p>I am trying to achieve how to put the validations error from backend to front end in rails</p>
  
  <p>Here is my <code>user.rb</code>: </p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_secure_password
  
    EMAIL_REGEX = /\A([^@\s]+)@((?:[a-z0-9]+\.)+[a-z]+)\z/i
    validates :name, presence: true
    validates :email, presence: true, uniqueness: {case_Sensitive:false }, format: { with: EMAIL_REGEX}
    validates :password, presence: true, length: { minimum: 5 }
  
    before_save :email_lowercase
  
    # makes email lowercase before user submits
  
    def email_lowercase
      email.downcase!
    end
  
  end
  </code></pre>
  
  <p>and here is my <code>user_controller.rb</code>:</p>
  
  <pre><code>  def create
      user = User.create(user_params)
      if user.valid?
        user.save
        redirect_to 'index'
      else
        user.errors.messages
        redirect_to '/users/new'
      end
    end
  </code></pre>
  
  <p>and this is my html form:</p>
  
  <pre><code>&lt;form action="/users" method="post"&gt;
      &lt;%= hidden_field_tag :authenticity_token, form_authenticity_token %&gt;
  
      &lt;input type="text" name="user[name]" placeholder="Name"&gt;&lt;br&gt;
      &lt;input type="text" name="user[email]" placeholder="Email"&gt;&lt;br&gt;
      &lt;input type="password" name="user[password]" placeholder="Password"&gt;&lt;br&gt;
      &lt;input type="password" name="user[confirm_pw]" placeholder="Confirm PW"&gt;
      &lt;input type="submit" value="Join"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>How can I puts out validations to html in rails ?</p>