Commit 9eb07b37 authored by royce-matthew's avatar royce-matthew

added basic pages

parent f00bfcee
class PagesController < ApplicationController
def index
@votes = Vote.all
@candidates = Candidate.all
@positions = Position.all
render "pages/index.html.erb"
end
def profile
before_action :authenticate_user!
@votes = Vote.all
@candidates = Candidate.all
@positions = Position.all
render "pages/index.html.erb"
end
end
\ No newline at end of file
class Candidate < ApplicationRecord
end
<center>
Voting App
</center>
<h4>Howdy <%=current_user.email%></h4>
You Voted for<br>
<ul>
<%current_user.votes.each do |v|%>
<li><%="#{v.candidate.position.name}: #{v.candidate.full_name}"%>
<p style="">Comments: <%=v.comments%>
</p>
</li>
<%end%>
</ul>
\ No newline at end of file
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root "pages#index"
end
class CreateCandidates < ActiveRecord::Migration[5.0]
def change
create_table :candidates do |t|
t.string :first_name
t.string :last_name
t.string :nickname
t.text :slogan
t.integer :position_id
t.timestamps
end
end
end
......@@ -10,7 +10,17 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160718134705) do
ActiveRecord::Schema.define(version: 20160718135122) do
create_table "candidates", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.string "nickname"
t.text "slogan"
t.integer "position_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
......
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
first_name: MyString
last_name: MyString
nickname: MyString
slogan: MyText
position_id: 1
two:
first_name: MyString
last_name: MyString
nickname: MyString
slogan: MyText
position_id: 1
require 'test_helper'
class CandidateTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# 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