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

fixed wording inconsistencies

parent 8ef422dd
...@@ -178,4 +178,4 @@ DEPENDENCIES ...@@ -178,4 +178,4 @@ DEPENDENCIES
web-console (~> 2.0) web-console (~> 2.0)
BUNDLED WITH BUNDLED WITH
1.10.4 1.12.5
...@@ -8,20 +8,20 @@ class CandidatesController < ApplicationController ...@@ -8,20 +8,20 @@ class CandidatesController < ApplicationController
render "admin/candidates/index.html.erb" render "admin/candidates/index.html.erb"
end end
def new def new
@position = Candidate.new @candidate = Candidate.new
render "admin/candidates/new.html.erb" render "admin/candidates/new.html.erb"
end end
def create def create
@candidate = Candidate.new(candidate_params()) @candidate = Candidate.new(candidate_params())
if @position.save if @candidate.save
redirect_to admin_candidate_path(@candidate.id) redirect_to admin_candidate_path(@candidate.id)
else else
render "admin/candidates/new.html.erb" render "admin/candidates/new.html.erb"
end end
end end
def update def update
@candidate = Candidate.find(params[:id]) @candidate = Candidate.find(params[:id])
if @candidate.update(candidate_params()) if @candidate.update(candidate_params())
redirect_to admin_candidate_path(@candidate.id) redirect_to admin_candidate_path(@candidate.id)
...@@ -29,30 +29,30 @@ class CandidatesController < ApplicationController ...@@ -29,30 +29,30 @@ class CandidatesController < ApplicationController
render "admin/candidate/edit.html.erb" render "admin/candidate/edit.html.erb"
end end
end end
def show def show
@candidate = Candidate.find(params[:id]) @candidate = Candidate.find(params[:id])
@votes = Vote.where(candidate_id: (@candidate.id)) @votes = Vote.where(candidate_id: (@candidate.id))
@votes_male = Array.new @votes_male = Array.new
@votes_female = Array.new @votes_female = Array.new
@votes.each do |vote| @votes.each do |vote|
if vote.user.gender == "Male" if vote.user.gender == "Male"
@votes_male.push(vote) @votes_male.push(vote)
else else
@votes_female.push(vote) @votes_female.push(vote)
end end
end end
end end
def destroy def destroy
@candidate = Candidate.find(params[:id]) @candidate = Candidate.find(params[:id])
@votes = Vote.where(candidate_id: (@candidate.id)) @votes = Vote.where(candidate_id: (@candidate.id))
@votes.destroy_all @votes.destroy_all
@candidate.destroy @candidate.destroy
redirect_to admin_candidates_path redirect_to admin_candidates_path
end end
def candidate_params def candidate_params
params.require(:candidate).permit! params.require(:candidate).permit!
end end
end end
end end
\ No newline at end of file
class CandidatesController < ApplicationController class CandidatesController < ApplicationController
def index def index
@positions = Position.all @candidates = Candidates.all
end end
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