美文网首页
where.not、map、代码格式

where.not、map、代码格式

作者: 程序萌 | 来源:发表于2017-05-03 09:38 被阅读0次

遇到的问题

下拉菜单显示("emall_code='bd' AND is_special='0'")的条件判断

解决方法

def self.order_names
    Emall.where.not("emall_code='bd' AND is_special='0'").map{ |emall| [emall.name, emall.id]}
  end

查询的资料

where.not
map的用法:

# 迭代并造出另一个阵列
a = ["a", "b", "c", "d"]
b = a.map {|x| x + "!" }
puts b.inspect
# 结果是 ["a!", "b!", "c!", "d!"]

注意的问题

待码格式
日志中打印的ms加载速度数,越低越好。

总结 Rails where用法

相关文章

网友评论

      本文标题:where.not、map、代码格式

      本文链接:https://www.haomeiwen.com/subject/gikktxtx.html