Commit 5fed7c3e authored by Galen Evilla's avatar Galen Evilla

added if else

parent 3a6e2d88
......@@ -2,6 +2,7 @@ module Admin
class CandidatesController < ApplicationController
before_action :authenticate_user!
def index
@candidates = Candidate.all
@positions = Position.all
render "admin/candidates/index.html.erb"
end
......
......@@ -2,6 +2,7 @@ module Admin
class PositionsController < ApplicationController
before_action :authenticate_user!
def index
@positions = Position.all
render "admin/positions/index.html.erb"
end
......@@ -42,6 +43,7 @@ module Admin
end
def show
@candidates = Candidate.all
@position = Position.find(params[:id])
render "admin/positions/show.html.erb"
end
......
......@@ -11,15 +11,19 @@
<div class="col-md-12">
<left>
<h1>Candidates</h1>
<div class="btn btn-info" role ="button">
<%= link_to "Add a Candidate", new_admin_candidate_path, :method => "get" %>
</div>
</left>
<% if @positions.size > 0 %>
<%@positions.each do |p|%>
<hr>
<h3><center><%=p.name%></center></h3>
<table>
<% if p.candidates.size > 0 %>
<table class="table table-hover">
<thead>
<th width ="40%"><center>Name</center></th>
<th><center>Slogan</center></th>
</thead>
<%p.candidates.each do |c|%>
<tr>
<td>
......@@ -27,12 +31,25 @@
<%=link_to c.full_name, admin_candidate_path(c.id)%>
</center>
</td>
<td>
<center>
<%=c.slogan%>
</center>
</td>
</tr>
<%end%>
<%else%>
<h4><center>No created candidates.</center></h4>
<%end%>
<center>
<div class="btn btn-info" role ="button">
<%= link_to "Add a Candidate", new_admin_candidate_path, :method => "get" %>
</div>
</center>
</table>
<%end%>
<% else %>
<h4>No created candidates.</h4>
<h4><center>No created candidates.</center></h4>
<% end %>
</div>
</div>
......
......@@ -26,11 +26,20 @@
<hr>
<h2>Candidates for <%=@position.name%></h2>
<% if @position.candidates.size > 0 %>
<ul>
<%@position.candidates.each do |c|%>
<li><%=link_to c.full_name, admin_candidate_path(c.id)%></li>
<%end%>
</ul>
<%else%>
<h4>No Candidates for <%= @position.name%> </h4>
<div class="btn btn-info" role ="button">
<%= link_to "Add a Candidate", new_admin_candidate_path, :method => "get" %>
</div>
<br>
<%end%>
<br>
<%= link_to "Back to Positions", admin_positions_path %>
......
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