Reputation: 1795
My index action is
def index
@users = User.without_user(current_user)
end
where without_user
is a scope
scope :without_user, lambda {|user| where("id <> :id", :id => user.id) }
I was wondering if this is the most secure way to implement this or is it vulnerable ?
Upvotes: 3
Views: 91
Reputation: 1468
It looks good, here sql injection will not work
Note Additional, In Rails 4, you can use not syntax:
scope :without_user, lambda {|user| where.not(id: user.id) }
Upvotes: 2
Reputation: 1313
looks fine. If the data is interpolated then it should be safe which looks like the case here.
Upvotes: 2