博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
创建数据方法
阅读量:4052 次
发布时间:2019-05-25

本文共 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/

你可能感兴趣的文章
Socket请求XML客户端程序
查看>>
Java中数字转大写货币(支持到千亿)
查看>>
Java.nio
查看>>
函数模版类模版和偏特化泛化的总结
查看>>
VMware Workstation Pro虚拟机不可用解决方法
查看>>
最简单的使用redis自带程序实现c程序远程访问redis服务
查看>>
redis学习总结-- 内部数据 字符串 链表 字典 跳跃表
查看>>
iOS 对象序列化与反序列化
查看>>
iOS 序列化与反序列化(runtime) 01
查看>>
iOS AFN 3.0版本前后区别 01
查看>>
iOS ASI和AFN有什么区别
查看>>
iOS QQ侧滑菜单(高仿)
查看>>
iOS 扫一扫功能开发
查看>>
iOS app之间的跳转以及传参数
查看>>
iOS __block和__weak的区别
查看>>
Android(三)数据存储之XML解析技术
查看>>
Spring JTA应用之JOTM配置
查看>>
spring JdbcTemplate 的若干问题
查看>>
Servlet和JSP的线程安全问题
查看>>
GBK编码下jQuery Ajax中文乱码终极暴力解决方案
查看>>