Commit 38b7caef authored by April Guian's avatar April Guian

Draft2

parent 7d1aec14
class PagesController < ApplicationController
def index
@candidates = Candidate.all
@positions = Position.all
@users = User.all
@votes = Vote.all
render "pages/index.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 :slogan %>
<%= f.input :position_id %>
<%= f.submit %>
<% end %>
<h1>Edit Candidate</h1>
<% if admin_signed_in? %>
Hello Admin!
<%= render partial: "form" %>
<%= link_to "Back to List of Positions", admin_candidates_path %>
<% else %>
You are not signed in. Please go to login page.
<% end %>
\ No newline at end of file
<h1>Add New Candidate</h1>
<%= render partial: "form" %>
<%= link_to "Back to List of Candidates", admin_candidates_path %>
\ No newline at end of file
<h1>Position: <%= @position.name %></h1>
<h2>Candidates:</h2>
<ul>
<% @candidates.each do |c| %>
<li><%= link_to c.last_name, admin_candidate_path(c.id) %></li>
<% end %>
</ul>
\ No newline at end of file
<%= simple_form_for([:admin, @position]) do |f| %>
<%= f.input :name %>
<%= f.submit %>
<% end %>
<h1>Edit Position</h1>
<% if admin_signed_in? %>
Hello Admin!
<%= render partial: "form" %>
<%= link_to "Back to List of Positions", admin_positions_path %>
<% else %>
You are not signed in. Please go to login page.
<% end %>
\ No newline at end of file
<h1>2016 Election</h1>
<table width="100%">
<tr>
<th>Position</th>
</tr>
<% @positions.each do |p| %>
<tr>
<td><%= p.name %></td>
<td>
<%= link_to "Show Candidates", admin_positions_path(positions.id) %>
</td>
</tr>
<% end %>
</table>
<h1>Add New Position</h1>
<%= render partial: "form" %>
<%= link_to "Back to List", admin_positions_path %>
\ No newline at end of file
<h1>Position: <%= @position.name %></h1>
<h2>Candidates:</h2>
<ul>
<% @candidates.each do |c| %>
<li><%= link_to c.last_name, admin_candidate_path(c.id) %></li>
<% end %>
</ul>
\ No newline at end of file
<%= simple_form_for(@candidate) do |f| %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.input :slogan %>
<%= f.input :position_id %>
<%= f.submit %>
<% end %>
<h1>Edit Candidate</h1>
<% if admin_signed_in? %>
Hello Admin!
<%= render partial: "form" %>
<%= link_to "Back to List of Positions", admin_candidates_path %>
<% else %>
You are not signed in. Please go to login page.
<% end %>
\ No newline at end of file
<h1>Add New Candidate</h1>
<%= render partial: "form" %>
<%= link_to "Back to List of Candidates", candidates_path %>
\ No newline at end of file
<h1>Position: <%= @position.name %></h1>
<h2>Candidates:</h2>
<ul>
<% @candidates.each do |c| %>
<li><%= link_to c.last_name, candidate_path(c.id) %></li>
<% end %>
</ul>
\ No newline at end of file
<h1>Mock Elections 2016</h1>
<%= link_to "Manage Positions Under Admin", admin_positions_path %>
<%= link_to "Manage Candidates Under Admin", admin_candidates_path %>
<hr>
<% @positions.each do |p| %>
<h2>(<%= p.id %>) <%= p.name %></h2>
<ul>
<% p.candidates.each do |c| %>
<li><%= link_to c.title, post_path(c.id) %></li>
<% end %>
</ul>
<%= link_to "View all Candidates", "/positions/#{p.id}" %>
<% end %>
\ No newline at end of file
<%= simple_form_for(@position) do |f| %>
<%= f.input :name %>
<%= f.submit %>
<% end %>
<h1>Edit Position</h1>
<% if admin_signed_in? %>
Hello User!
<%= render partial: "form" %>
<%= link_to "Back to List of Positions", admin_posts_path %>
<% else %>
You are not signed in. Please go to login page.
<% end %>
\ No newline at end of file
<h1>2016 Election</h1>
<table width="100%">
<tr>
<th>Position</th>
</tr>
<% @positions.each do |p| %>
<tr>
<td><%= p.name %></td>
<td>
<%= link_to "Show Candidates", positions_path(positions.id) %>
</td>
</tr>
<% end %>
</table>
<h1>Add New Position</h1>
<%= render partial: "form" %>
<%= link_to "Back to List", positions_path %>
\ No newline at end of file
<h1>Position: <%= @position.name %></h1>
<h2>Candidates:</h2>
<ul>
<% @candidates.each do |c| %>
<li><%= link_to c.last_name, candidate_path(c.id) %></li>
<% end %>
</ul>
\ No newline at end of file
Rails.application.routes.draw do
devise_for :users
root to: "pages#index"
#resources
resources :candidates, :positions
#namespace :admin do
# resources :posts
#end
namespace :admin do
resources :candidates, :positions
end
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