Skip to content

Instantly share code, notes, and snippets.

@mwlang
Created July 16, 2013 20:21
Show Gist options
  • Select an option

  • Save mwlang/6012302 to your computer and use it in GitHub Desktop.

Select an option

Save mwlang/6012302 to your computer and use it in GitHub Desktop.
has_and_belongs_to_many :normal_events,
:join_table => 'events_practices',
:conditions => "type = 'NormalEvent' AND status_id = #{Status[:published].id}",
:association_foreign_key => "event_id",
:order => 'starts_on ASC'
has_and_belongs_to_many :normal_events_future,
:class_name => 'NormalEvent',
:join_table => 'events_practices',
:conditions => "type = 'NormalEvent' AND status_id = #{Status[:published].id} AND starts_on >= '#{0.days.ago.to_s(:db)}'",
:association_foreign_key => "event_id",
:order => 'starts_on ASC'
has_and_belongs_to_many :normal_events_past,
:class_name => 'NormalEvent',
:join_table => 'events_practices',
:conditions => "type = 'NormalEvent' AND status_id = #{Status[:published].id} AND starts_on < '#{0.days.ago.to_s(:db)}'",
:association_foreign_key => "event_id",
:order => 'starts_on DESC'
has_and_belongs_to_many :campus_interviews,
:join_table => 'events_practices',
:conditions => "type = 'CampusInterview' AND status_id = #{Status[:published].id}",
:association_foreign_key => "event_id",
:order => 'starts_on ASC'
has_and_belongs_to_many :campus_interviews_future,
:class_name => 'CampusInterview',
:join_table => 'events_practices',
:conditions => "type = 'CampusInterview' AND status_id = #{Status[:published].id} AND starts_on >= '#{0.days.ago.to_s(:db)}'",
:association_foreign_key => "event_id" ,
:order => 'starts_on ASC'
has_and_belongs_to_many :campus_interviews_past,
:class_name => 'CampusInterview',
:join_table => 'events_practices',
:conditions => "type = 'CampusInterview' AND status_id = #{Status[:published].id} AND starts_on < '#{0.days.ago.to_s(:db)}'",
:association_foreign_key => "event_id" ,
:order => 'starts_on DESC'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment