Sam Liokumovich
Sam Liokumovich

Reputation: 23

Ruby On Rails Submit Buttons sometimes doesn't work?

I have a very simple website that has a scaffold articles with a string title, and text description. Sometimes my submit button doesn't work for edit and new. Then after I refresh the page the buttons start to work again. I'm using bootstrap-sass 3.3.6, rails 5.0.0.

This is the code for my form:

<%= form_for(article, :html => {class: "form-horizontal", role: "form"}) do |f| %>
<div class="form-group">
  <div class="control-label col-sm-2">
    <%= f.label :title %>
  </div>
  <div class="col-sm-6">
    <%= f.text_field :title, class: "form-control", placeholder: "Title of article", autofocus: true%>
  </div>
</div>

<br />
  <div class="form-group">
    <div class="control-label col-sm-2">
        <%= f.label :description %>
    </div>
    <div class="col-sm-6">
      <%= f.text_area :description, rows: 5, class: "form-control", placeholder: "Body of the article", autofocus: true%>
    </div>
  </div>
</div>
<div class="form-group">
        <%= f.submit class:"btn btn-primary btn-lg" %>
</div>

What could be causing this?

Upvotes: 0

Views: 1683

Answers (2)

Aleks Ordyniec
Aleks Ordyniec

Reputation: 1

I know the question is old, but I had the same problem and the fix above did not help (no stray tags). It turns out that closing the message/warning section in class="panel-heading" caused it. Removing this bootstrap class fixed the issue.

Upvotes: 0

Tony Vincent
Tony Vincent

Reputation: 14272

You have a stray </div> tag. This type of error is most frequently one generated by invalid HTML. Various sources of errors can be:

  1. missing < or >
  2. HTML tag not closed
  3. Orphaned HTML closing tag (where no opening one is related);
  4. Forms nested within table or tr tags (within td is allowed).

If properly formatting html doesn't work for you, then it can be a turbolinks issue, you can try disabling turbolinks like :data-no-turbolink => true (just a patch not the solution)

Upvotes: 3

Related Questions