activerecord find all NOT included in an array

I have an array of team names from another part of code and I want to find all the Teams not in that array. I've tried the following and it doesn't work.

@team_exclude_list = ['Team 1', 'Team 2', 'Team 3']
@teams = Team.where("name != ?", @team_exclude_list)

This is in Rails 3 and the Googles aren't giving me much love.


I've never done this with a string field, but perhaps this will work:

@teams = Team.where("name NOT IN (?)", @team_exclude_list)

Need Your Help

Vista Console App?

windows ruby windows-vista console

I'm doing a fair bit of work in Ruby recently, and using

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.