修改后的 Rails 教程应用程序中的部分表单未呈现

Form partial not rendering in modified Rails Tutorial app

构建 Rails 教程,但对其进行修改以构建用于 HR 目的的员工时钟应用程序。在我的注册页面上,部分表单未在视图中呈现。

new.html.erb

    <% provide(:title, 'New Employee Sign-up') %>
    <% provide(:button_text, 'Register Me') %>
    <h1>Register your information</h1>
    <div class="row">
      <div class="col-md-6 col-md-offset-3">
        <% render 'form' %>
      </div>
    </div>

_form.html.erb

    <%= form_for(@employee, url: newemployee_path) do |f| %>
      <%= render 'shared/error_messages', object: @employee %>

      <%= f.label :firstname %>
      <%= f.text_field :firstname, class: 'form-control' %>

      <%= f.label :lastname %>
      <%= f.text_field :lastname, class: 'form-control' %>

      <%= f.label :email %>
      <%= f.email_field :email, class: 'form-control' %>

      <%= f.label :ssn %>
      <%= f.text_field :ssn, class: 'form-control' %>

      <!-- <%= f.label :dateofhire %> -->
      <!-- <%= f.text_field :dateofhire, class: 'form-control' %> -->

      <%= f.label :password %>
      <%= f.password_field :password, class: 'form-control' %>

      <%= f.label :password_confirmation %>
      <%= f.password_field :password_confirmation, class: 'form-control' %>

      <%= f.submit yield(:button_text), class: "btn btn-primary" %>
    <% end %>

('date of hire' 字段已被注释掉,因为我没有为该字段将推送到数据库的内容准备好正则表达式验证和迁移。)

什么可能导致表单未呈现? Click here to see what I'm seeing in the preview pane:

问题出在您的 render 电话上。

应该是<%= render 'form' %>,这样才能在视图中输出结果。