Simple form error messages appearing next to the form submission in Ruby on Rails
<p>I'm working on a form, and I'm having a problem with the form submissions. If a user messes up or skips one of the entries, all of the error messages render at the top of the page. I'm wondering if I can get them to render next to each submission instead?</p>

<p>My controller looks like</p>

<pre><code>def new
 @form_submission ||= FormSubmission.new
end

def create
 @form_submission = FormSubmission.new(form_submission_params)

 if @form_submission.save
   redirect_to thank_you_path
 else
   render :new
 end
end
</code></pre>

<p>With my view looking like</p>

<pre><code> .field
  = f.label :first_name, required: false, class: "font required-field"
 = f.text_field :first_name, :required =&gt; "", class: "stretch test"
</code></pre>

<p>and my CSS</p>

<pre><code>.font{
 vertical-align: text-bottom;
 font-size: 15px;
 font-weight: bold;
 font-family: "Helvetica Neue";
 height: 15px;
}

.required-field::before{
content: ' *';
float: right;
color: red;
padding-left: 5px;
}

.test:valid{
  border: 1px solid #00aeef;
}

.test:invalid{
  border: 1px solid red;
}
</code></pre>