此SQL语句易受SQL注入攻击吗



我的索引操作是

def index
  @users = User.without_user(current_user)
end

其中without_user是范围

scope :without_user, lambda {|user| where("id <> :id", :id => user.id) }

我想知道这是实现这一点的最安全的方式,还是易受攻击?

看起来不错。如果数据是插值的,那么它应该是安全的,就像这里的情况一样。

看起来不错,这里的sql注入不起作用

另外,在Rails4中,您可以使用not语法:

scope :without_user, lambda {|user| where.not(id: user.id) }

最新更新