Rails 5.1 - 出现在表单字段上的文本

时间:2018-03-26 10:20:28

标签: ruby-on-rails forms

我正在Rails应用程序上构建一个表单,其中一个部分我在文本字段(学校组)中得到一些随机文本,我不知道为什么 - School group - text in field

这是表单的代码,我使用了错误的字段类型吗?

<% provide :title, "Add Staff Member" %>

<%= form_for @user do |f| %>

  <div class="form-group row">
    <%= f.label :firstname, 'First Name', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.text_field :firstname, class: 'form-control' %>
    </div>
  </div>

  <div class="form-group row">
    <%= f.label :nickname, 'Nickname', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.text_field :nickname, class: 'form-control' %>
    </div>
  </div>

  <div class="form-group row">
    <%= f.label :surname, 'Last Name', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.text_field :surname, class: 'form-control' %>
    </div>
  </div>

  <div class="form-group row">
    <%= f.label :email, 'Email Address', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.email_field :email, class: 'form-control' %>
    </div>
  </div>

  <div class="form-group row">
    <%= f.label :email, 'Send Welcome Email?', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= check_box_tag :send_welcome_email %>
    </div>
  </div>

  <div class="form-group row">
    <%= f.label :user_groups, 'School Group', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.text_field :user_groups, class: 'form-control' %>
    </div>
  </div>

  <div class="form-group row">
    <%= f.label :timezone, 'Timezone', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.time_zone_select(:timezone, nil, {default: @user.timezone}, {class: 'form-control custom-select'}) %>
    </div>
  </div>

  <hr>

  <h2>Create Password</h2>

  <p><small>Password must be at least six characters long</small></p>

  <div class="form-group row">
    <%= f.label :password, 'New Password', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.password_field :password, autocomplete: "off", class: 'form-control' %>
    </div>
  </div>

  <div class="form-group row">
    <%= f.label :password_confirmation, 'Confirm Password', class: 'col-sm-2' %>
    <div class="col-sm-10">
      <%= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control' %>
    </div>
  </div>


  <div class="actions">
    <%= f.submit 'Submit', class: 'btn btn-primary' %>
  </div>
<% end %>

为了这个表格的利益,学校团体的领域实际上可以留空,但我想要那里的领域。我如何摆脱这个文本?

1 个答案:

答案 0 :(得分:2)

它不是一些随机文本,它可能是您User@user中的关联,可能列名称与关联名称相同或者可能是一个类型。