zoukankan      html  css  js  c++  java
  • rails in query

    http://stackoverflow.com/questions/4307411/how-to-express-a-not-in-query-with-activerecord-rails

    I'm using this:
    
    Topic.where('id NOT IN (?)',actions)
    Where actions is an array with: [1,2,3,4,5]
    
    Edit:
    
    For Rails 4 notation:
    
    Article.where.not(title: ['Rails 3', 'Rails 5']) 

    需求是 v1.2以前版本(v1.2不用过滤)的接口中过滤掉电影、电视剧、动漫、综艺以外的频道

    两种方法都是好用的

        if params[:version] < "1.2"
          arr = ["电影","电视剧","综艺","动漫"]
          #default_navi_channels = CmsChannel.where(title: arr).where('state = 1 and channel_type = ?' ,'cibn_navi_channel').order('position asc')
          default_navi_channels = CmsChannel.where('title IN (?)', arr).where('state = 1 and channel_type = ?' ,'cibn_navi_channel').order('position
        end 
  • 相关阅读:
    C++基础学习1-编译与链接
    html学习
    使用BP拦截POST请求包
    2019.9.17
    搭建LAMP环境
    2019.9.16
    2019.9.12
    2019.9.11
    手脱无名壳tslgame_rl
    一款自制壳的脱壳
  • 原文地址:https://www.cnblogs.com/iwangzheng/p/5210190.html
Copyright © 2011-2022 走看看