Tag: 将 pginate

将两个ActiveRecord :: Relation与OR组合,而不是AND,返回一个Relation而不是一个Array,以便稍后能够分页

a和b是ActiveRecord :: Relation对象,它们返回相同类型的对象(在本例中为Micropost对象) a.class => ActiveRecord::Relation b.class => ActiveRecord::Relation a.first => Micropost(…) b.first => Micropost(…) #They both return the same type of objects c=a+b c.class => Array #This is not what i’m looking for c=a|b c.class => Array #Not what i’m looking for either c=(a or b) c.class => ActiveRecord::Relation #But it is just a, […]