Skip to content

Instantly share code, notes, and snippets.

@Sailias
Created April 18, 2011 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sailias/925686 to your computer and use it in GitHub Desktop.
Save Sailias/925686 to your computer and use it in GitHub Desktop.
scope :current, where(:current=>true}
validate :only_one_current
protected
def only_one_current
errors.add_to_base("Only one event can be current") if Event.current.reject{|c| c.eql?(self)}.size>0
end
def before_create
if self.current?
Event.current.last.update_attribute("current", false)
end
end
get "current_event" => "events#current_event"
get "current_event/days" => "days#current_days"
get "current_event/days/registrants" => "registrants#current_registrants"
get "current_event/days/registrants" => "registrants#search"
get "current_event/days/registrants" => "registrants#all_schedules"
get "current_event/days/registrants" => "registrants#schedule"
get "current_event/days/registrants" => "registrants#edit_attendance"
post "current_event/days/registrants" => "registrants#update_attendance"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment