title: Custom SQL query without Corresponding Table
body: <p>I have a SQL query that isn't table-specific and I don't know how to handle it with Ruby On Rails.</p>
  
  <p>Here my SQL query (you don't need to understand it):</p>
  
  <pre>SELECT type, actor_id, events.created_at, photo_id, photos.user_id FROM 
  (SELECT 'comment' AS type, user_id AS actor_id, created_at, photo_id FROM comments
  UNION
  SELECT 'classification' AS type, user_id AS actor_id, created_at, photo_id FROM classifications) 
  AS events
  INNER JOIN photos ON photo_id = photos.id
  WHERE user_id = #{@user.id}
  ORDER BY created_at DESC
  LIMIT 9</pre>
  
  <p>I tried to create a model and use a find_by_sql:</p>
  
  <pre><code>
  class RecentActivity ActiveRecord::Base
    attr_accessor :type, :actor_id, :created_at, :photo_id, :user_id
  end
  </code></pre>
  
  <p>I get:</p>
  
  <pre>Mysql::Error: Table 'mysite_development.recent_activities' doesn't exist: SHOW FIELDS FROM `recent_activities`</pre>
  
  <p>How can I avoid this message? Is there any alternative solution?</p>