本文共 636 字,大约阅读时间需要 2 分钟。
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" } ])转载地址:http://tecci.baihongyu.com/