a long variety of improvements and tweaks
[selectricity] / app / controllers / site_controller.rb
1 class SiteController < ApplicationController
2   layout 'hc'
3   model :user, :election
4
5   def index
6     # if the person claims they are logged in
7     if session[:user]
8
9       # check to see that we actually have record of them
10       if User.find_all(["id = ?", session[:user].id]).length == 1
11         # if we have record of them, grab the list of their elections
12         session[:user] = User.find(session[:user].id)
13         @current_elections = session[:user].elections.sort do |a,b|
14           b.enddate <=> a.enddate
15         end
16       else
17         # if we have no record of them, set the session id back to
18         # nothing and start again
19         session[:user] = nil
20       end
21     end
22   end
23
24 end

Benjamin Mako Hill || Want to submit a patch?