我正在使用Ruby on Rails 3.0.10和我想“减去”两个ActiveRecord::Relation
“实体”并且再次返回一个ActiveRecord::Relation
。也就是说,我有两个ActiveRecord::Relation
对象(@articles
和@articles_checked
)和下面的代码:ActiveRecord ::关系问题
@unchecked_articles = @articles - @articles_checked
# $ @unchecked_articles.class
# => Array
@unchecked_articles.method_call
# raise a NoMethodError error (read above for more information).
上面的代码,反正返回一个Ruby Array
所以我不能 “玩”(使用where
,order
,.. 。陈述),因为我通常与ActiveRecord::Relation
。在控制台它会生成以下错误:
NoMethodError (undefined method 'method_call' for #<Array:0x000001063dd658>)
我怎样才能检索ActiveRecord::Relation
对象后,我作出了上述变化?或更好,有一种方法可以完成我想用@unchecked_articles
检索的内容?