Ruby on rails 3 我尝试使用复选框标记和mysql,但为什么总是将数据插入布尔值为null?
下面是我的mysql表defineRuby on rails 3 我尝试使用复选框标记和mysql,但为什么总是将数据插入布尔值为null?,ruby-on-rails-3,Ruby On Rails 3,下面是我的mysql表define class CreateStudinfors < ActiveRecord::Migration def change create_table :studinfors do |t| t.string :cname , limit: 45, :null => false t.string :ename , limit: 45, :null => false t.date :b
class CreateStudinfors < ActiveRecord::Migration
def change
create_table :studinfors do |t|
t.string :cname , limit: 45, :null => false
t.string :ename , limit: 45, :null => false
t.date :birthday
t.string :gender , limit: 1, :null => false
t.string :address , limit: 45, :null => false
t.string :telephone , limit: 45, :null => false
t.string :mobile_phone , limit: 45, :null => false
t.string :school , limit: 45, :null => false
t.string :email , limit: 45, :null => false
t.boolean :work
t.boolean :study
t.boolean :travel
t.boolean :lifeplan
t.text :other , :null => false
t.string :sales , limit: 45, :null => false
t.string :introduce , limit: 45, :null => false
t.timestamps
end
end
end
class CreateStudinforsfalse
t、 字符串:ename,限制:45,:null=>false
t、 日期:生日
t、 字符串:性别,限制:1,:null=>false
t、 字符串:地址,限制:45,:null=>false
t、 字符串:电话,限制:45,:null=>false
t、 字符串:移动电话,限制:45,:null=>false
t、 字符串:school,limit:45,:null=>false
t、 字符串:email,限制:45,:null=>false
t、 布尔值:工作
t、 布尔:研究
t、 布尔值:旅行
t、 布尔:生命计划
t、 text:other,:null=>false
t、 字符串:sales,limit:45,:null=>false
t、 string:introduct,limit:45,:null=>false
t、 时间戳
结束
结束
结束
这是我表格中的一部分
<div class="field">
<%= f.label :make select %><br />
<%= check_box_tag "work" %>
</div>
有什么建议吗?谢谢,请出示您的表格好吗?如果是特定模型的表格,例如:
<%= form_for @studinfor do |f| %>
<% end %>
然后,您需要创建如下复选框:
<%= form_for @studinfor do |f| %>
<%= f.checkbox :work %>
<% end %>
只需一个更正,真正要使用的函数是
f。复选框:带下划线的工作
)