Ruby on Rails Tuesday, February 26, 2013



On Monday, 25 February 2013 22:23:48 UTC-5, Bruno Santos wrote:

Try something like this:

Plan.where("user_id not in (#{[3,4,7].join(', ')})")


This easier, and won't risk SQL injection if that array has user-generated content:

Plan.where('user_id NOT IN ?', [3,4,7])

--Matt Jones
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3Vz__3m3N8gJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment