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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5b9e56b8-0b8b-463f-98dc-4b71e23d5f98%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/346b0cfce5ed6dc61cc1c856dd32eab5%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
@Joel: It isn''t Hash#merge, but ActiveRecord::SpawnMethods#merge -- Dheeraj Kumar On Thursday 8 August 2013 at 10:00 PM, Joel Pearson wrote:> 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. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/346b0cfce5ed6dc61cc1c856dd32eab5%40ruby-forum.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9D1334928E17401D95331B403CBEEA23%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.