Search code examples
ruby-on-railsruby-on-rails-4page-refreshsimple-form-for

Rails4 Page Needs Refresh Simpleform Submit


I am having an issue in my Rails4 app that requires me to refresh a page before I am able to submit a form.

When I click on a link to render a page with a form on it, the page loads and displays the form, however, looking at the source code, it only shows the code from the previous page. It is not until I refresh the page that the correct source code will show and the form is able to submit.

Also, FYI, I am using Simple-form. Anyone familiar with this?

From the controller:

  def new
    @application = Application.new
  end

From the view:

<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<div class="applicationform">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title" style="text-align:center"><strong>Application</strong></h3></div>
<div class="panel-body">

<%= simple_form_for(@application) do |f| %>
<%= f.error_notification %>
<%= f.input :details %>
<div class="text-center submitbutton">
<%= f.button :submit, :class => "btn btn-large btn-primary" %>
</div>
<% end %>

</div>
</div>
</div>
</div>
</div>
</div>

Solution

  • I fixed this issue by changing:

    <body> to... <body data-no-turbolink="true">
    

    Not sure what the implications are by doing this, but the forms now submit without requiring a page refresh.