Created
June 29, 2011 05:24
-
-
Save wallace/1053211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edit: fixing the SQL injection | |
class User < ActiveRecord::Base | |
... | |
scope :not_a_member_of, lambda { |project_id| | |
sanitized_join_condition = sanitize_sql_array( | |
["LEFT OUTER JOIN 'memberships' ON | |
'memberships'.'user_id' = #{self.quoted_table_name}.'id' AND | |
'memberships'.'project_id' = ?", project_id] | |
) | |
joins(sanitized_join_condition). | |
where("'memberships'.'project_id' IS NULL") | |
} | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment