Skip to content

Instantly share code, notes, and snippets.

@meltzerj
Created May 5, 2011 06:25
Show Gist options
  • Select an option

  • Save meltzerj/956633 to your computer and use it in GitHub Desktop.

Select an option

Save meltzerj/956633 to your computer and use it in GitHub Desktop.
RECENT_EVENTS_CONDITION = '(actor_type = \'User\' AND actor_id IN (SELECT followed_id FROM relationships WHERE follower_id = #{id}))'
has_many :recent_events, :class_name => "TimelineEvent",
:conditions => :filter_event,
:finder_sql => 'SELECT timeline_events.* FROM timeline_events
WHERE ' + RECENT_EVENTS_CONDITION + '
ORDER BY timeline_events.created_at DESC',
:counter_sql => 'SELECT COUNT(*) FROM timeline_events
WHERE ' + RECENT_EVENTS_CONDITION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment