Forum: Ruby on Rails Issue with mering ActiveRecord query results

3d0f832ab83163c0b0923260a86b6932?d=identicon&s=25 Sumit Srivastava (Guest)
on 2013-08-07 10:36
(Received via mailing list)
class ABC
def'starts_at <= ?','(ends_at > ? ||
ends_at IS NULL)',


  def self.recently_completed`

    self.completed.where("completed_at > ?", 2.days.ago)`


The issue is when I do:

( + ABC.recently_completed).columns_hash

This gives error, undefined method `columns_hash' for #<Array:.......

When I do:


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.
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
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.
Ce5e201eca55d4f79d0ead9acc91d544?d=identicon&s=25 Dheeraj Kumar (Guest)
on 2013-08-08 18:50
(Received via mailing list)

It isn't Hash#merge, but ActiveRecord::SpawnMethods#merge

Dheeraj Kumar
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.