include, "-" , A B, foreign_key. ( (feature_locations), .)
, features.id = 9 AND features.id = 1. features.id.
, : location_features, feature_id. , feature_id location_id .
, , , location_ids ( ), , : ( )
def self.having_all_feature_ids(*ids)
location_ids = Feature.find_all_by_id(ids).map(&:location_ids).inject{|a,b| a & b}
self.find(location_ids)
end
1: *ids , ( , " " ) .
2: inject - . : " , , .., . , (a b), " & ", " " - , . , , , , . , .
EDIT: , sql- - , group_concat, , , :)