Commit 81edefce authored by Jego Reyes's avatar Jego Reyes

added profile, voting statistics, attributes for users, fixed functionality.

parent 0a0c9184
No preview for this file type
class PagesController < ApplicationController
def index
@positions = Position.all
@users = User.all
@candidates = Candidate.all
render "pages/index.html.erb"
end
end
\ No newline at end of file
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
validates :first_name, presence: true
validates :last_name, presence: true
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
end
\ No newline at end of file
......@@ -4,6 +4,10 @@
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :first_name, required: true, autofocus: true %>
<%= f.input :last_name, required: true, autofocus: true %>
<%= f.input :birthday, required: true, autofocus: true %>
<%= f.input :gender, required: true, autofocus: true %>
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>
<%= f.input :password_confirmation, required: true %>
......
......@@ -14,8 +14,13 @@
<h4 style="color:#0080ff;margin-left:100px">
<% if user_signed_in? %>
Hello <%= current_user.email %>! <br>
<h4 style="margin-left:100px"><%= link_to "Profile", "/profiles"%></h4>
<%= link_to('Log Out', destroy_user_session_path, :method => :delete) %>
<h4 style="margin-left:100px"><%= link_to "Candidates", candidates_path %></h4>
<h4 style="margin-left:100px"><%= link_to "Positions", positions_path %></h4>
<h4 style="margin-left:100px"><%= link_to('Log Out', destroy_user_session_path, :method => :delete) %> </h4>
<% else %>
<h5 style="color:#0080ff;margin-left:100px">
You're not signed in.
......@@ -23,12 +28,13 @@
<%= link_to "Register", new_user_registration_path %>
</h5>
<% end %>
</h4>
<h4 style="margin-left:100px"><%= link_to "Candidates", candidates_path %></h4>
<h4 style="margin-left:100px"><%= link_to "Positions", positions_path %></h4>
</div>
......
<link rel"stylesheet" type="text/css" href="application.css">
<h1>Election 2016</h1>
<h3>Hello <%= current_user.last_name %></h3>
\ No newline at end of file
<h1>Voting Statistic</h1>
\ No newline at end of file
Rails.application.routes.draw do
devise_for :users
root to: "pages#index"
resources :candidates
get "/about", to: "pages#about"
get "/votingstatistic", to: "pages#statistic"
get "/profiles", to: "pages#profiles"
resources :candidates
resources :positions
end
class AddMoreFieldsToUsers < ActiveRecord::Migration
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :birthday, :date
add_column :users, :gender, :string
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160717095601) do
ActiveRecord::Schema.define(version: 20160718054341) do
create_table "candidates", force: :cascade do |t|
t.string "first_name"
......@@ -41,6 +41,10 @@ ActiveRecord::Schema.define(version: 20160717095601) do
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "first_name"
t.string "last_name"
t.date "birthday"
t.string "gender"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
......
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