Commit 1eaf9d2d authored by Kristoff Sison's avatar Kristoff Sison

fixed wording inconsistencies

parent 8ef422dd
......@@ -178,4 +178,4 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
1.10.4
1.12.5
......@@ -8,20 +8,20 @@ class CandidatesController < ApplicationController
render "admin/candidates/index.html.erb"
end
def new
@position = Candidate.new
@candidate = Candidate.new
render "admin/candidates/new.html.erb"
end
def create
@candidate = Candidate.new(candidate_params())
if @position.save
if @candidate.save
redirect_to admin_candidate_path(@candidate.id)
else
render "admin/candidates/new.html.erb"
end
end
def update
@candidate = Candidate.find(params[:id])
def update
@candidate = Candidate.find(params[:id])
if @candidate.update(candidate_params())
redirect_to admin_candidate_path(@candidate.id)
......@@ -29,30 +29,30 @@ class CandidatesController < ApplicationController
render "admin/candidate/edit.html.erb"
end
end
def show
@candidate = Candidate.find(params[:id])
def show
@candidate = Candidate.find(params[:id])
@votes = Vote.where(candidate_id: (@candidate.id))
@votes_male = Array.new
@votes_female = Array.new
@votes.each do |vote|
if vote.user.gender == "Male"
@votes_male.push(vote)
else
@votes_female.push(vote)
end
@votes = Vote.where(candidate_id: (@candidate.id))
@votes_male = Array.new
@votes_female = Array.new
@votes.each do |vote|
if vote.user.gender == "Male"
@votes_male.push(vote)
else
@votes_female.push(vote)
end
end
end
def destroy
@candidate = Candidate.find(params[:id])
def destroy
@candidate = Candidate.find(params[:id])
@votes = Vote.where(candidate_id: (@candidate.id))
@votes.destroy_all
@candidate.destroy
redirect_to admin_candidates_path
end
def candidate_params
params.require(:candidate).permit!
end
@votes = Vote.where(candidate_id: (@candidate.id))
@votes.destroy_all
@candidate.destroy
redirect_to admin_candidates_path
end
def candidate_params
params.require(:candidate).permit!
end
end
end
\ No newline at end of file
class CandidatesController < ApplicationController
def index
@positions = Position.all
@candidates = Candidates.all
end
end
\ No newline at end of file
<%= simple_form_for([:admin, @position]) do |f| %>
<%= f.input :name %>
<%= f.submit %>
<% end %>
\ No newline at end of file
<h1>Admin Edit Position</h1>
<%= render partial: "form" %>
<%= link_to "Back to Positions", admin_positions_path %>
\ No newline at end of file
<h1>Admin New Position</h1>
<%= render partial: "form" %>
<%= link_to "Back to Positions", admin_positions_path %>
<h1>Position: <%= @position.name %></h1>
<h2>Candidates:</h2>
<ul>
<% @candidates.each do |c| %>
<li><%= link_to "#{c.first_name}"+" #{c.last_name}", admin_candidate_path(c.id) %></li>
<% end %>
</ul>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment