Skip to content

Instantly share code, notes, and snippets.

@meltzerj
Created May 26, 2011 07:10
Show Gist options
  • Select an option

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

Select an option

Save meltzerj/992695 to your computer and use it in GitHub Desktop.
'((actor_type = \'User\' AND actor_id IN (SELECT followed_id FROM relationships WHERE follower_id = #{id})) AND ((secondary_subject_type = \'Video\' AND subject_type <> \'Profile\' AND secondary_subject_id NOT IN (SELECT id FROM videos WHERE user_id = #{id})) OR (secondary_subject_type = \'User\' AND secondary_subject_id <> #{id}) OR (secondary_subject_type = \'nil\') OR (subject_type = \'Profile\' AND secondary_subject_id NOT IN (SELECT id FROM videos WHERE user_id = #{id}) AND subject_id NOT IN (SELECT id FROM profiles WHERE user_id = #{id}))))'
belongs_to :actor, :polymorphic => true
belongs_to :subject, :polymorphic => true
belongs_to :secondary_subject, :polymorphic => true
has_many :user_notifications
has_many :recent_events, :class_name => "TimelineEvent",
: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