1 class ElectionsController < ApplicationController
4 render :action => 'list'
8 @election_pages, @elections = paginate :elections, :per_page => 10
12 @election = Election.find(params[:id])
16 @election = Election.new
20 @election = Election.new(params[:election])
22 flash[:notice] = 'Election was successfully created.'
23 redirect_to :action => 'new_candidates', :id => @election.id
25 render :action => 'new'
30 @election = Election.find( params[:id] )
34 election = Election.find( params[:id] )
35 @candidate = Candidate.new
36 @candidate.name = params[:newcandidate]
38 election.candidates << @candidate
39 render :partial => 'candidate_line'
43 candidate = Candidate.find( params[:id] )
48 @election = Election.find(params[:id])
52 @election = Election.find( params[:id] )
56 @election = Election.find( params[:id] )
60 @election = Election.find(params[:id])
61 if @election.update_attributes(params[:election])
62 flash[:notice] = 'Election was successfully updated.'
63 redirect_to :action => 'show', :id => @election
65 render :action => 'edit'
70 election = Election.find(params[:id]).destroy
71 redirect_to :action => 'list'