Rails表单提交错误NOT NULL

时间:2015-11-05 02:43:39

标签: ruby-on-rails forms devise

所以我正在为我的rails应用程序构建一个设计用户注册表单,并在“用户”表中添加了一个列,用于'类型,'目标是拥有两种不同类型的用户。在“用户”表中将类型指定为整数。提交表单时,我收到错误。不知道为什么。当我提交表格时,我会输入一个' 1'对于该类型只是为了看它是否有效而且它没有。

这是错误。

SQLite3::ConstraintException: NOT NULL constraint failed: users.type: 
INSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at", 
"confirmation_token", "confirmation_sent_at") VALUES (?, ?, ?, ?, ?, ?)

这里是表单代码。

<h2>Project Creator Registration</h2>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<div class="form-group" align="left">
  <%= f.label :name %><br />
  <%= f.text_field :name, autofocus: true, required: true, class: "form-control" %>
</div>

<div class="form-group" align="left">
  <%= f.label :email %><br />
  <%= f.email_field :email, autofocus: true, required: true, class: "form-control" %>
</div>

<div class="form-group" align="left">
  <%= f.label :type %><br />
  <%= f.number_field :type, autofocus: true, required: true, class: "form-control" %>
</div>

<div class="field" align="left">
  <%= f.label :password %>
  <% if @minimum_password_length %>
  <em>(<%= @minimum_password_length %> characters minimum)</em>
  <% end %><br />
  <%= f.password_field :password, required: true, autocomplete: "off", class: "form-control"  %>
</div>

<div class="field" align="left">
  <%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation, required: true, autocomplete: "off", class: "form-control" %>
</div></br>

<div class="form-group">
  <%= f.submit class: "btn btn-primary btn-lg" %>
</div>

<% end %>

<%= render "devise/shared/links" %>

任何建议???

0 个答案:

没有答案