Rails Postgres ActiveRecord通过查询中的id和自定义数组的交集进行匹配

时间:2017-02-10 06:02:34

标签: ruby-on-rails postgresql activerecord

我的帖子是has_and_belongs_to_many :categories

我需要这样的东西:

Post.where('here category_ids intersects with custom array [1,2,3]').all

1 个答案:

答案 0 :(得分:0)

您可以加入类别和查询类别

NSArray *arrayToBeConvertedInToString = @[@"This", @"is", @"an", @"array"];
NSString * result = [[arrayToBeConvertedInToString valueForKey:@"description"] componentsJoinedByString:@" "];
NSLog(@"Array in string: %@", result);