class Student < ActiveRecord::Base
def initialize ( stu_num, name, department )
initialize
end
end
s1 = Student.new
s1. stu_num = "00000001"
s1.name = "first"
s1.department = "computer"
s1.save
Student.new do | s2|
s2.stu_num = "00000002"
s2.name = "two"
s2.department = "home"
s2.save
end
s3 = Student.new(
:stu_num => "000000003",
:name => "three",
:department => "town"
)
s3.save
s4 = Student.create(
:stu_num => "000000004",
:name => "four",
:department => "country"
)
s5 = Student.create(
[{
:stu_num => "000000005",
:name => "five",
:department => "china"
},{
:stu_num => "000000006",
:name => "six",
:department => "English"
}
])
创建数据方法
最新推荐文章于 2022-11-28 12:16:16 发布