Class: RailsVoter::ElectionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_voter/elections_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
# File 'app/controllers/rails_voter/elections_controller.rb', line 19

def create
  if election.save
    redirect_to elections_path
  else
    render :new
  end
end

#newObject



13
14
15
16
17
# File 'app/controllers/rails_voter/elections_controller.rb', line 13

def new
  10.times do
    election.election_details.new
  end
end

#updateObject



27
28
29
30
31
32
33
# File 'app/controllers/rails_voter/elections_controller.rb', line 27

def update
  if election.update(election_params)
    redirect_to elections_path
  else
    render :new
  end
end