Rails4范围与参数(Rails4 scope with parameters)
我不知何故在rails文档中找不到有关如何将某些参数放入命名范围的任何地方,像这样的东西
范围:by_id, - > {where:id = id}
I somehow cannot find any place in the rails documentation about how to put some params into a named scope, f.e. something like this
scope :by_id, -> { where :id = id }
最满意答案
scope :by_id, ->(id) {where (:id => id)}这应该工作
scope :by_id, ->(id) {where (:id => id)}this should work
更多推荐
发布评论