在修改后的Rails Tutorial app中表单部分不呈现

时间:2016-07-12 00:19:22

标签: ruby-on-rails-4 railstutorial.org

构建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 %>

(雇用日期&#39;字段已被注释掉,因为我没有进行正则表达式验证和迁移准备好该字段将进入数据库的内容。)

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

1 个答案:

答案 0 :(得分:2)

问题出在render来电。

它应该是<%= render 'form' %>,以便在视图中输出结果。