Added a candidates page under views\admin\candidates and edited the layout

parent 932a32f9
......@@ -4,7 +4,7 @@ class CandidatesController < ApplicationController
def index
@candidates = Candidate.all
@positions = Postion.all
@positions = Position.all
render "admin/candidates/index.html.erb"
end
def new
......
......@@ -3,7 +3,7 @@ class PositionsController < ApplicationController
def show
@position = Position.find(params[:id])
@candidates = @candidate.positions
render "categories/show.html.erb"
render "positions/show.html.erb"
end
end
\ No newline at end of file
<%= simple_form_for([:admin, @candidate]) do |f| %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.input :nickname %>
<%= f.input :slogan %>
<%= f.submit %>
<% end %>
\ No newline at end of file
<h1>Admin New Candidate</h1>
<%= render partial: "form" %>
<%= link_to "Back to Candidates", admin_candidates_path %>
<h1>Admin Candidates</h1>
<hr>
<%= link_to("New Candidate", new_admin_candidate_path) %>
<hr>
<table width="100%">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Nickname</th>
<th>Slogan</th>
<th>Actions</th>
</tr>
<% @candidates.each do |candidate| %>
<tr>
<td><%= candidate.first_name %></td>
<td><%= candidate.last_name %></td>
<td><%= candidate.nickname %></td>
<td><%= candidate.slogan %></td>
<td>
<%= link_to "Show", admin_candidate_path(candidate.id) %>
<%= link_to "Edit", edit_admin_candidate_path(candidate.id) %>
<%= link_to "Delete", admin_candidate_path(candidate.id), method: :delete, data: { confirm: 'Are you sure?' } %>
</td>
</tr>
<% end %>
</table>
<h1>Admin New Candidate</h1>
<%= render partial: "form" %>
<%= link_to "Back to Candidates", admin_candidates_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>
......@@ -18,4 +18,3 @@
<% end %>
</table>
<hr>
<%= link_to "Back to Homepage", root_path %>
\ No newline at end of file
......@@ -9,7 +9,7 @@
<body>
<% if user_signed_in? %>
<p>You are logged in as <%= current_user.email %>.</p><%= link_to "Log Out", destroy_user_session_path, method: :delete %> ||
<%= "You are logged in as: #{current_user.email}" %> &nbsp; <%= link_to "Log Out", destroy_user_session_path, method: :delete %> ||
<% else %>
<%= "" %>
<% end %>
......
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