摘要:
new 在持久化activerecord对象并持久化到数据库的步骤: 1.new一个对象并返回 2.手动设置对象属性 3.save方法保存对象 create将这三步整合到一起,创建对象的同时根据参数对对象属性赋值,并把它保存到数据库中,返回更新了数据库属性的对象实例。 转载于:http://blog 阅读全文
摘要:
获取当前的文件名称 puts __FILE__ 获取当前文件的目录名称 puts File.dirname(__FILE__) 获取当前文件的完整名称 当要获取完整的路径时需要require 'pathname',代码如下: require ‘pathname’ puts Pathname.new( 阅读全文
摘要:
delete_all 是一条sql 删除所有数据。比如; delete from tables where id > 0; destory_all 是一条一条删除。比如:循环执行 delete from tables where id = 1; delete from tables where id 阅读全文