I am using Ruby on Rails 3.0.7 and I would like to keep the ActiveRecord::Relation class after doing this (in the below code article_category_relationships represents an has_many :through Record Association):
# @article.article_category_relationships.class # => ActiveRecord::Relation
@article.article_category_relationships.map(&:category).class # => Array
It should be something like this:
@article.article_category_relationships.map(&:category).class # => ActiveRecord::Relation
It seems that the map method makes losing the ActiveRecord::Relation class.
Is it possible to keep the ActiveRecord::Relation class after run an iterative method? If so how can do?
Note: I would like that in order to keep using of all methods provided by Ruby on Rails for the ActiveRecord::Relation class (.where(...), .count, …).
If you are using ruby 1.9, check out tap: