2.dynamic find by methods

简介:
先来看这段代码:

incomplete方法用来查询所有未完成的任务, conditions这个option后面的参数是一个数组,'complete = ?' ?是一个占位符,false是它的实际值,这个语句等价于:
@tasks = Task.find(:all, :conditions=>"complete = false")

----
这个方法也可以用find_by_... 方法来写,可读性更强:





本文转自 fsjoy1983 51CTO博客,原文链接:http://blog.51cto.com/fsjoy/97098,如需转载请自行联系原作者
目录
相关文章
|
9月前
Unknown custom element: <add-employee> - did you register the component correctly? For red cursive c
原因: 1.组件名没写对(导入和注册不对应) 2.components少写了个s 3.组件命名最好是驼峰命名 4.导入时语法错误 5.代码中有两个components,后一个的值把前一个覆盖了 6.组件直接循环套用了
|
4月前
|
JavaScript
[Vue warn]_ Avoid using non-primitive value as key, use string_number value instea
[Vue warn]_ Avoid using non-primitive value as key, use string_number value instea
|
前端开发 JavaScript
前端vue:解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
前端vue:解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
1187 0
前端vue:解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
|
JavaScript 算法 前端开发
Property xxx was accessed during render but is not defined on instance
目前el-form的model主要用表单验证的,也就是配合el-form的rules和el-form-item的prop来使用的。不信的话,你可以增加一个rules和prop(为了调用验证方法,也el-form也加一个ref属性,相当于id或者class选择器的意思),但是不写model,然后验证的话,会提示缺少model,导致无法验证成功。
Property xxx was accessed during render but is not defined on instance
Duplicate methods named spliterator with the parameters () and () are inherited from the types Colle
Duplicate methods named spliterator with the parameters () and () are inherited from the types Colle
49 0
No injector for custom defined data type的解决办法
No injector for custom defined data type的解决办法
224 0
No injector for custom defined data type的解决办法
custom field further usage - add into UI and report
custom field further usage - add into UI and report
113 0
custom field further usage - add into UI and report
component set load logic - why coms_pcat_bob is accessed during product search
component set load logic - why coms_pcat_bob is accessed during product search
111 0
component set load logic - why coms_pcat_bob is accessed during product search
OPA 15 - find existing item by its type.note
Created by Wang, Jerry, last modified on Nov 08, 2015
124 0
OPA 15 - find existing item by its type.note