Rails 着陆页上的表单导致页面刷新到页面底部

Rails form on landing page cause page refresh to go to bottom of page

我使用 partials 在目标网页底部添加了一个表单

<body id= "page-top" data-spy="scroll" data-target=".navbar-fixed-top">
    <%= render "layouts/header" %>
    <%= render 'product' %> 
    <%= render 'people' %>
    <%= render 'contact' %>

  </body>

<div class="section landing-section">
  <div class= "container">
    <div class="row">
      <div class="col-md-8 ml-auto mr-auto">
        <h2>Keep in touch?</h2>
        <%= render "contacts/form" %> 
      </div>
    </div>
  </div>
</div>

我从我的联系人文件夹中呈现了表格我的联系表格在下面 并在

中添加到我的静态页面控制器
def home 
@contact = Contact.new 
end

<%= form_for @contact, class: "contact-form"  do |f| %>
  <div class="form-group">
      <%= f.label :name %><br />
      <%= f.text_field :name, autofocus: true, required: true, class: "form-control", placeholder: "name" %>
    </div>
    <div class="form-group">
      <%= f.label :email %><br />
      <%= f.email_field :email, autofocus: true, required:true, class: "form-control", placeholder: "email" %>
    </div>
    <div class="form-group">
      <%= f.label :message %><br />
      <%= f.text_area :message, autofocus: true, rows:4, required:true,  class: "form-control", placeholder: "send us your thoughts and feelings" %>
    </div>
   <div class="btn-group">
        <%= f.submit "Send Message", class: "btn btn-danger btn-lg btn-fill" %>
    </div>
<% end %>

表单有效,但每次我刷新登陆页面或在浏览器中加载它时,页面都会登陆联系表单(页面底部)

我需要做什么才能让页面正常加载(到页面顶部)的任何想法

您应该删除自动对焦:所有字段都为真。