Commit 446866c2 authored by April Guian's avatar April Guian

Added CRUD to Positions

parent 4f024caf
...@@ -7,7 +7,7 @@ class CandidatesController < ApplicationController ...@@ -7,7 +7,7 @@ class CandidatesController < ApplicationController
def show def show
@candidate = Candidate.find(params[:id]) @candidate = Candidate.find(params[:id])
#@user = @candidate.user @user = @candidate.user
#@users = User.all #@users = User.all
render "candidates/show.html.erb" render "candidates/show.html.erb"
end end
......
...@@ -2,14 +2,21 @@ ...@@ -2,14 +2,21 @@
<% @positions.each do |c| %> <% @positions.each do |c| %>
<h2>(<%= c.id %>) <%= c.name %></h2> <h2>(<%= c.id %>) <%= c.name %></h2>
<%= link_to "Edit Position", edit_admin_position_path(c.id) %>
<%= link_to "Delete Position", admin_position_path(c.id), method: :delete, data: { confirm: 'Are you sure?' } %>
<ul> <ul>
<% c.candidates.each do |p| %> <% c.candidates.each do |p| %>
<li><%= link_to "#{p.first_name} #{p.last_name}" , admin_candidate_path(p.id) %></li> <li><%= link_to "#{p.first_name} #{p.last_name}" , admin_candidate_path(p.id) %></li>
<% end %> <% end %>
</ul> </ul>
<%= link_to "View all Candidates under #{c.name}" , "admin/positions/#{c.id}" %> <%= link_to "View all Candidates under #{c.name}" , "admin/positions/#{c.id}" %>
<% end %> <% end %>
<hr>
<%= link_to("Add New Position", new_admin_position_path) %> <%= link_to("Add New Position", new_admin_position_path) %>
<hr> <hr>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<td><%= c.slogan %></td> <td><%= c.slogan %></td>
<td><%= c.position.name %></td> <td><%= c.position.name %></td>
<td> <td>
<%= link_to "Show", position_path(c.id) %> <%= link_to "Show", candidate_path(c.id) %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
......
<h1> <%= Create a profile page that displays all the candidates that the user voted %> </h1>
\ No newline at end of file
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