I try working check_box_tag and mysql but why always insert data to Boolean is null?
below is my mysql table 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 :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
this is my part of my form ..
<div class="field">
<%= f.label :make select %><br />
<%= check_box_tag "work" %>
</div>
any advise? thanks and please
Could you please show your form as well? If it is a form for a specific model such as:
<%= form_for @studinfor do |f| %>
<% end %>
Then you need to create the check box like this:
<%= form_for @studinfor do |f| %>
<%= f.checkbox :work %>
<% end %>
精彩评论