4_move_find_into_model

简介:
在controller中经常要对某一个model做同一种查询,这样会造成代码重复,为了符合DRY原则,将查询放到model里。
接着第三节的例子:
在task Model里定义类方法:
 
那么在task_controller和projects_controller里就可以调用这个方法:
 




本文转自 fsjoy1983 51CTO博客,原文链接:http://blog.51cto.com/fsjoy/103011,如需转载请自行联系原作者
目录
相关文章
|
9月前
|
Python
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
find
find
67 0
|
Web App开发 JavaScript
$(...).find is not a function
$(...).find is not a function
182 0
Find a way
Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki.
130 0
|
自然语言处理 Python
解决spacy3.2报错:Can‘t find model ‘en‘.
(1)下载spacy一直没成功,把pip install spacy改成conda install spacy就可以了; (2)在命令行输入 python3 -m spacy download en 来下载英语语言包(如果是其他语言则下载其他包了),不过en现在最好用全称en_core_web_sm,这一步也可以先下载tar再pip install en_core_web_md-2.2.5.tar.gz(但是注意把文件放对路径)。 然后测试下代码:
554 0
how to find the original page containing a given image
how to find the original page containing a given image
how to find the original page containing a given image
How to judge if one model data is out of date
Created by Wang, Jerry, last modified on Jan 12, 2015
How to judge if one model data is out of date
OPA 13 - ok(oButton,find the Create button);
Created by Wang, Jerry, last modified on Nov 08, 2015
OPA 13 - ok(oButton,find the Create button);