首页 > 其他 > 详细

12月21日

时间:2017-12-21 11:12:44      阅读:204      评论:0      收藏:0      [点我收藏+]

destroy_all and delete_all

Destroy the records by instantiating each record and calling its #destroy method.在删除前实例化每条记录,并回调callback execution. 

?? :如果想要快速删除,如果这个动作不涉及associations or callbacks, use delete_all instead. 

 


 

豆知识: 

Transaction: the process of doing business. 

 

在iterm中输入alias,可以显示所有设置的别名:例子ll的别名是“ls -lh”显示详细的文件内容 

 

语言学习法:

1. 用身体记忆(肌肉记忆,第一步是反复做,而不是试图理解背后的逻辑。学习语言包括配合肢体动作)

2. 跟读。(模仿,纠正) 

3. 实际环境中使用。(编程就是直接开发项目,边开发边学。语言就是用,说起来。)

4. 不要被语言本身所限制,语言的目的是沟通,只要符合沟通的目的,可以灵活使用。

 


Active Record Callbacks:简单学一下:

Callbacks are hooks into the life cycle of an Active Record object that allow you to trigger logic before or after an alteration of the object state.

总共有19种回叫。 如 before_validation, before_create, before_destroy.

继续看api文档:http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html 


 

12月21日

原文:http://www.cnblogs.com/chentianwei/p/8078523.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!