title: How to concatenate two ActiveRecord queries in Rails
body: <p>I have simple app with a user model, role model, message model with a recipient.
  A user has many messages through role 
  and a role has many messages through recipients and a user also has many messages through recipients.</p>
  
  <p>the recipient model has a user_id, role_id and message_id</p>
  
  <p>and now i want to display all the messages of the user including his role messages and his personal message in one query. How can i accomplish this.</p>
  
  <pre><code> role model
  
   has_many :recipients
   has_many :received_messages, :class_name =&gt; 'Message', :order =&gt; 'created_at desc', through: :recipients
  
   user model
   has_many :roles
   has_many :received_messages, :class_name =&gt; 'Message', :order =&gt; 'created_at desc', through: :roles, :uniq =&gt; true
   has_many :recipients
   has_many :private_messages, :class_name =&gt; 'Message', :order =&gt; 'created_at desc', through: :recipients
  
   message model
   has_many :recipients
   has_many :roles, :through =&gt; :recipients
   has_many :users, :through =&gt; :recipients
  </code></pre>
  
  <p>With all these in place how am i going to fetch the users messages both his role messages and his private messages</p>
  
  <p>example</p>
  
  <pre><code>def all_messages
    @all_messages = current_user.#all messages scope here#
  end
  </code></pre>