Combine two ActiveRecord Query results

I currently have two active record queries that I would like to combine together

joins("join relationships ON user_id = followed_id").
              where("follower_id = #{}")


where(:user_id =>

Basically I want the results of the second one to appear with the first similar to a UNION statement in SQL. Can it be done in ActiveRecord in this way?

I would prefer to use a union rather that have to join all the followed_ids in a string and use the IN clause in sql.

Any ideas?

-----Edit------ I am looking for a way to get this to work with lazy loading


Use relation & relation:

Model.joins("join relationships ON user_id = followed_id").where("follower_id = {}") & Model.where(:user_id =>

This was useful for me:

Model.where(...) | Model.where(...)

Need Your Help

How to force browser to reload cached CSS/JS files?

javascript css caching auto-versioning

I have noticed that some browsers (in particular, Firefox and Opera) are very zealous in using cached copies of .css and .js files, even between browser sessions. This leads to a problem when you u...

How can we make show/hide password input in angular js with bootstrap 3?

angularjs twitter-bootstrap-3 angular-ui-bootstrap

I want to make show/hide password input in angular js with bootstrap 3, the toggle option needs to be inside the input. Can you provide a snippet or example on that. Thanks a million.