Skip to content

Instantly share code, notes, and snippets.

@trek
Created October 24, 2008 17:48
Show Gist options
  • Select an option

  • Save trek/19523 to your computer and use it in GitHub Desktop.

Select an option

Save trek/19523 to your computer and use it in GitHub Desktop.
class Conference
has_many :attendees, :class_name => 'Person', :through => :attendance
def Conference.next_upcoming
self.find!(:first, :conditions => ['starting_at > ? and visibile = ?' Time.now, true])
rescue RecordNotFound
self.most_recent
end
def most_recent
...
end
end
class Attendance
belongs_to :conference
belongs_to :person
end
class Person
has_many :conference, :through => :attendance
before_create :salt_password, :encrypt_password
def salt_password
...
end
def encrypt_password
...
end
end
class ConferencesController
def current
Conferences.next_upcoming
end
end
class AttendencesController
def create
Attendence.create(params[:attendence])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment