Added positions_controller and views\positions\show.html.erb; Updated...

Added positions_controller and views\positions\show.html.erb; Updated views\layouts\application.html.erb.
parent cf427e63
class PositionsController < ApplicationController
before_action :authenticate_user!
def show
@position = Position.find(params[:id])
@candidates = @candidate.positions
render "categories/show.html.erb"
end
end
\ 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> <br> || <%= link_to "Log Out", destroy_user_session_path, method: :delete %>
<p>You are logged in as <%= current_user.email %>.</p><%= link_to "Log Out", destroy_user_session_path, method: :delete %> ||
<% else %>
<%= "" %>
<% end %>
......
<h1>Official Election Ballot</h1>
<% if user_signed_in? %>
<h2>Please take a look at our candidates!</h2>
<hr>
<%= link_to "Manage Candidates", candidates_path %>
<hr>
<% @positions.each do |p| %>
<h2>(<%= p.id %>.) <%= p.name %></h2>
<ul>
<% p.candidates.each do |c| %>
<li><%= link_to c.nickname, candidate_path(c.id) %></li>
<% end %>
</ul>
<%= link_to "View all Candidates", "/positions/#{p.id}" %>
<% end %>
<% else %>
<h4>You are not signed in. Please <%= link_to "Login", new_user_session_path %> or <%= link_to "Sign Up", new_user_registration_path %> to proceed with voting.</h2>
<h4>You are not signed in. Please <%= link_to "Login", new_user_session_path %> or <%= link_to "Sign Up", new_user_registration_path %> to proceed with voting.</h4>
<% end %>
\ No newline at end of file
<h1>Position: <%= @position.name %></h1>
<h2>Candidates:</h2>
<ul>
<% @candidates.each do |c| %>
<li><%= link_to c.nickname, candidate_path(c.id) %></li>
<% end %>
</ul>
\ 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