]> projects.mako.cc - selectricity-live/blob - app/controllers/application.rb
merged in link to blog
[selectricity-live] / app / controllers / application.rb
1 # Filters added to this controller will be run for all controllers in the application.
2 # Likewise, all the methods added will be available for all controllers.
3
4 class ApplicationController < ActionController::Base
5   include AuthenticatedSystem
6   helper :user
7   require_dependency "user"
8
9   include Sitealizer
10   before_filter :add_stylesheets
11   #before_filter :use_sitealizer
12    
13   def initialize
14     @stylesheets = []
15
16         
17     # this is defined is a sketchy way in the sitealizer mixin
18     # initalize. since i'm overloading that, i'm calling it here
19     $visits = [] unless $visits
20   end
21             
22   def add_stylesheets
23     file = "#{Dir.pwd}/public/stylesheets/#{controller_name}.css"
24     if File.exists? file
25       @stylesheets << controller_name
26     end
27   end
28
29   #both election_controller and quickvote_controller need this method
30   def sort_candidates
31     @vote = Vote.find(params[:id])
32
33     @vote.rankings.each do |ranking|
34       ranking.rank = params['rankings-list'].index(ranking.candidate.id.to_s) + 1
35       ranking.save
36     end
37     render :nothing => true
38   end
39 end

Benjamin Mako Hill || Want to submit a patch?