class ABC def self.active self.live.where('starts_at <= ?', Time.now).where('(ends_at > ? || ends_at IS NULL)', Time.now) end def self.recently_completed` self.completed.where("completed_at > ?", 2.days.ago)` end The issue is when I do: (ABC.active + ABC.recently_completed).columns_hash This gives error, undefined method `columns_hash' for #<Array:....... When I do: (ABC.active).merge(ABC.recently_completed) The query being run is actually combination of the two. They are not run independently as I expected. I need a way to write the code as to run the queries separately and then merge the results but not as an array.
on 2013-08-07 10:36
on 2013-08-08 18:30
If you were going to use Hash#merge to remove duplicates between the two result sets, you might as well just use Array#uniq on the Array.
on 2013-08-08 18:50
@Joel: It isn't Hash#merge, but ActiveRecord::SpawnMethods#merge -- Dheeraj Kumar