Commit 45d1e7ef authored by aprilangelo's avatar aprilangelo

Inital

parents
File added
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use sqlite3 as the database for Active Record
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem 'sqlite3'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
gem 'jquery-smooth-scroll-rails', '~> 0.0.5'
gem 'jquery-easing-rails', '~> 0.0.2'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'better_errors'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'simple_form'
gem 'devise'
# Active if Windows users
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
\ No newline at end of file
GEM
remote: http://rubygems.org/
specs:
actionmailer (4.2.5.1)
actionpack (= 4.2.5.1)
actionview (= 4.2.5.1)
activejob (= 4.2.5.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5.1)
actionview (= 4.2.5.1)
activesupport (= 4.2.5.1)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5.1)
activesupport (= 4.2.5.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5.1)
activesupport (= 4.2.5.1)
globalid (>= 0.3.0)
activemodel (4.2.5.1)
activesupport (= 4.2.5.1)
builder (~> 3.1)
activerecord (4.2.5.1)
activemodel (= 4.2.5.1)
activesupport (= 4.2.5.1)
arel (~> 6.0)
activesupport (4.2.5.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
bcrypt (3.1.11)
bcrypt (3.1.11-x86-mingw32)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (9.0.5)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
devise (4.2.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.1)
responders
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.7.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.5.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-easing-rails (0.0.2)
railties (>= 3.1.0)
jquery-rails (4.1.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-smooth-scroll-rails (0.0.5)
railties (~> 4.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
nokogiri (1.6.8-x86-mingw32)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
orm_adapter (0.5.0)
pkg-config (1.1.7)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5.1)
actionmailer (= 4.2.5.1)
actionpack (= 4.2.5.1)
actionview (= 4.2.5.1)
activejob (= 4.2.5.1)
activemodel (= 4.2.5.1)
activerecord (= 4.2.5.1)
activesupport (= 4.2.5.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5.1)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.5.1)
actionpack (= 4.2.5.1)
activesupport (= 4.2.5.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.2.2)
rdoc (4.2.2)
json (~> 1.4)
responders (2.2.0)
railties (>= 4.2.0, < 5.1)
sass (3.4.22)
sass-rails (5.0.5)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simple_form (3.2.1)
actionpack (> 4, < 5.1)
activemodel (> 4, < 5.1)
spring (1.7.2)
sprockets (3.6.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.1.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
sqlite3 (1.3.11-x86-mingw32)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (5.0.0)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
tzinfo-data (1.2016.6)
tzinfo (>= 1.0.0)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
warden (1.2.6)
rack (>= 1.0)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
better_errors
byebug
coffee-rails (~> 4.1.0)
devise
jbuilder (~> 2.0)
jquery-easing-rails (~> 0.0.2)
jquery-rails
jquery-smooth-scroll-rails (~> 0.0.5)
rails (= 4.2.5.1)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simple_form
spring
sqlite3
turbolinks
tzinfo-data
uglifier (>= 1.3.0)
web-console (~> 2.0)
BUNDLED WITH
1.12.5
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
File added
// Agency Theme JavaScript
(function($) {
"use strict"; // Start of use strict
// jQuery for page scrolling feature - requires jQuery Easing plugin
$('a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: ($($anchor.attr('href')).offset().top - 50)
}, 1250, 'easeInOutExpo');
event.preventDefault();
});
// Highlight the top nav as scrolling occurs
$('body').scrollspy({
target: '.navbar-fixed-top',
offset: 51
});
// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a:not(.dropdown-toggle)').click(function() {
$('.navbar-toggle:visible').click();
});
// Offset for Main Navigation
$('#mainNav').affix({
offset: {
top: 100
}
})
})(jQuery); // End of use strict
This diff is collapsed.
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<script src="js/jqBootstrapValidation.js"></script>
<script src="js/contact_me.js"></script>
<script src="js/agency.min.js"></script>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
This diff is collapsed.
// Place all the styles related to the Candidates controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
This diff is collapsed.
// Place all the styles related to the Positions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
/*
* Author: Carlos Alvarez
* URL: http://alvarez.is
*
* Project Name: Landing Sumo - Theme 20
* URL: http://LandingSumo.com
* Version: 1.0
* Exclusive Freebie for BlackTie.co
*/
@import url(http://fonts.googleapis.com/css?family=Lato:300,400,700,900);
body {
font-family: 'Lato', sans-serif;
background: #fff;
margin: 0;
color: #5a5a5a;
overflow-x: hidden;
}
.arrow
{
width: 40px;
}
.home
{
background-color: #f8ca00;
}
h1, h4 {
font-family: 'Lato', sans-serif;
font-weight: 300;
text-align: center;
}
h3{
font-family: 'Lato', sans-serif;
font-weight: 300;
color: #5a5a5a;
text-align: center;
}
.alert
{
color: #31708f;
background-color: #d9edf7;
border-color: #bce8f1;
width: 30%;
}
.alert hr
{
border-top-color: #a6e1ec;
}
.alert .alert-link
{
color: #245269;
}
}
h2 {
font-family: 'Lato', sans-serif;
font-weight: 700;
padding-bottom: 4px;
text-align: center;
}
h5 {
font-family: 'Montserrat', sans-serif;
font-weight: 400;
}
h6 {
font-family: 'Lato', sans-serif;
font-weight: 300;
color: #fff;
font-size: 9px;
}
p {
padding: 0;
font-family: 'Lato', sans-serif;
font-weight: 500;
letter-spacing: 1px;
color: #666;
margin-top: 10px;
text-align: center;
}
.note
{
font-weight: 400;
font-family: 'Lato', sans-serif;
color: blue;
text-transform: lowercase;
}
.photo
{
width: 100px;
text-align: center;
}
html, body {
height: 100%;
}
.centered {
text-align: center;
}
.mt {margin-top: 8px;}
a {
font-family: 'Lato', sans-serif;
padding: 0;
margin: 0;
text-decoration: none;
color: #666;
font-size: 13px;
}
a:hover {
text-decoration: none;
color:#21437E;
border-bottom: 3px solid;
}
a:active,
{
border-bottom: 3px solid;
}
.nopadding {
padding: 0px !important;
margin: 0px;
}
/* FORM CONFIGURATION */
input {
color: #666;
font-size: 14px;
min-height: 40px;
border-radius: 5px;
line-height: 10px;
border: 1px solid #999;
padding-left: 10px;
padding-right: 10px;
margin-bottom: 10px;
background-color: #fff;
opacity: 0.9;
-webkit-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.submit-input {
float: center;
width: 40%;
text-align: left;
margin-right: 2px;
}
/*Buttons Configuration */
.btn {
border-radius: 5px;
font-size: 15px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: #EAEAEA;
color: #5a5a5a;
padding: 10px 70px 10px 70px;
}
.btn:hover, .btn:focus {
border-radius: 5px;
font-size: 15px;
letter-spacing: 1px;
text-transform: uppercase;
padding-left:50px;
padding-right:50px;
background-color: #F5F5F5;
color: #5a5a5a;
padding: 10px 70px 10px 70px;
-webkit-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.btn-conf {
border-radius: 5px;
font-size: 15px;
letter-spacing: 1px;
text-transform: uppercase;
padding: 10px 70px 10px 70px;
}
/* BODY SECTION */
.vbox {
padding-left: 15px;
padding-right: 15px;
padding-bottom: 10px;
width: 60%;
}
.pbox {
padding-left: 15px;
padding-right: 15px;
padding-bottom: 10px;
width: 60%;
}
.team
{
margin-left: 180px;
text-align: center;
}
.color
{
border-radius: 5px;
background-color: #F8CA00;
padding-right: 20px;
padding-left: -10px;
padding-top: 20px;
padding-bottom: 20px;
list-style-type: none;
margin-top: 20px;
}
.self ul {
padding-top: 10px;
}
.self ul li {
background-repeat: no-repeat;
padding-left:26px;
background-position: 0 .1em;
height:25px;
display:block;
margin-top:-2px;
}
#logo
{
width: 100px;
}
\ No newline at end of file
// Place all the styles related to the Votes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :birthday, :password, :password_confirmation, :first_name, :last_name, :gender])
#good to know for now
#devise_parameter_sanitizer.permit(:sign_in)
devise_parameter_sanitizer.permit(:account_update, keys:[:email, :password, :birthday, :password_confirmation, :current_password, :first_name, :last_name, :gender])
end
end
class CandidatesController < ApplicationController
before_action :set_candidates, only: [:show, :edit, :update]
before_action :authenticate_admin!
def index
@candidates = Candidate.all
end
def new
@candidate = Candidate.new
end
def create
@candidate = Candidate.new(candidate_params)
if @candidate.save
redirect_to candidates_path, notice: "Candidate #{@candidate.first_name} has been created!"
else
render :new
end
end
def edit
end
def update
if @candidate.update(candidate_params)
redirect_to candidates_path, notice: "Candidate #{@candidate.first_name} has been updated!"
else
render :edit
end
end
def show
@candidate = Candidate.find(params[:id])
# @users_by_gender = User.all.group_by(&:gender)
end
def destroy
@candidate = Candidate.find(params[:id])
if @candidate.votes.count.to_i == 0.to_i
@candidate.destroy
redirect_to candidates_path, notice: "#{@candidate.first_name} has been deleted"
else
redirect_to candidates_path, notice: "#{@candidate.first_name} can't be deleted"
end
end
private
def set_candidates
@candidate = Candidate.find(params[:id])
end
def candidate_params
params.require(:candidate).permit!
end
private
# def confirm_presence_of_votes
# # unless Position.count(["votes.position_id != #{id}"]) > 0
# # errors.add_to_base "Cannot destroy because position has votes already"
# # end
# #if Position.pluck(:id).vote.count > 0
# unless votes.count.nil?
# self.errors[:base] << "Cannot delete shipment while its invoice exists."
# return false
# # errors.add_to_base("cannot delete")
# # return false
# end
end
class PositionsController < ApplicationController
before_action :set_positions, only: [:show, :edit, :update]
before_action :authenticate_admin!, only: [:index, :new, :update, :create, :destroy, :show, :edit]
def index
@positions = Position.all
end
def new
@position = Position.new
end
def create
@position = Position.new(position_params)
if @position.save
redirect_to positions_path, notice: "Position #{@position.name} has been created!"
else
render :new
end
# @position = Position.new
# @position.name = params[:name]
# if @position.save!
# redirect_to positions_path, notice: "Position #{@position.name} has been created!"
# else
# render :new
# end
end
def edit
end
def update
if @position.update(position_params)
redirect_to positions_path, notice: "Position #{@position.name} has been updated!"
else
render :edit
end
end
def show
@position = Position.find(params[:id])
@candidates = @position.candidates
end
def destroy
@position = Position.find(params[:id])
@counter = 0
@position.candidates.each do |c|
if c.votes.count > 0
@counter = @counter + 1
else
end
end
if @counter == 0
@position.destroy
redirect_to positions_path, notice: "#{@position.name} has been deleted"
else
redirect_to positions_path, notice: "#{@position.name} cant be deleted"
end
end
private
def set_positions
@position = Position.find(params[:id])
end
def position_params
params.require(:position).permit!
end
end
class VotesController < ApplicationController
before_action :authenticate_user!, except: [:index]
def index
@candidates_by_positions = Candidate.all.group_by(&:position_id)
end
def vote
@candidates_by_positions = Candidate.all.group_by(&:position_id)
@vote = Vote.new
end
def checkout
@vote = Vote.new(vote_params)
if user_signed_in?
@vote.user_id = current_user.id
@vote.gender = current_user.gender
@vote.position_id = @vote.candidate.position_id
end
@all_positions = Position.pluck(:id)
@candidates_by_positions = Candidate.all.group_by(&:position_id)
id = @vote.position_id
@all_votes = current_user.votes.all.pluck(:position_id)
if @all_votes.include?(id) == false
@vote.save
flash[:notice] ="You have voted successfully! "
redirect_to candidate_list_path
else
flash[:notice] ="Vote not counted. You can only vote one candidate per position."
redirect_to candidate_list_path
end
# if @all_votes == []
# @vote.save
# else
# @all_votes.each do |v|
# if v == @vote[:position_id]
# render :vote
# break
# else
# redirect_to candidate_list_path
# @vote.save
# end
# end
# end
# id = @vote.position_id
# @all_votes.each do |v|
# if v != id
# @vote.save
# redirect_to candidate_list_path
# else
# render :vote
# end
# end
# @all_positions.each do |p|
# if @all_votes.detect{ |e| @all_votes.count(e) > 1 } == p
# render :vote
# else
# @vote.save
# end
# end
# if @all_votes.detect {|e| @all_votes.rindex(e) != @all_votes.index(e) } == nil
# @vote.save
# redirect_to candidate_list_path
# else
# render :vote
# end
# a
# if @all_votes.detect{ |e| @all_votes.count(e) > 1 } == nil
# @vote.save
# redirect_to candidate_list_path
# else
# render :vote
# end
# @all_positions = Position.all.pluck(:id)
# @all_votes = current_user.votes.all.pluck(:position_id)
# @all_positions.each do |p|
# @all_votes
# if @vote.save
# redirect_to candidate_list_path
# else
# redirect_to candidate_list_path, notice: "Voting successful!"
# end
# else
# render :vote
# end
# if user.votes.all.pluck(:position_id) & Position.all.pluck(:id)
# if @vote.save
# redirect_to candidate_list_path
# else
# redirect_to candidate_list_path, notice: "Voting successful!"
# end
# else
# render :vote
# end
end
def profile_page
@votes = current_user.votes
end
private
def vote_params
params.require(:vote).permit!
end
end
module ApplicationHelper
end
module CandidatesHelper
end
module PositionsHelper
end
module VotesHelper
end
class Admin < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :first_name, presence: true
validates :last_name, presence: true
validates :gender, presence: true
validates :birthday, presence: true
end
class Candidate < ActiveRecord::Base
def to_s
"#{first_name} #{last_name}"
end
belongs_to :position
has_many :votes
validates :first_name, presence: true
validates :last_name, presence: true
validates :nickname, presence: true, uniqueness: true
validates :slogan, presence: true, uniqueness: true
validates :position_id, presence: true
# before_destroy :confirm_presence_of_votes
# private
# def confirm_presence_of_votes
# # unless Position.count(["votes.position_id != #{id}"]) > 0
# # errors.add_to_base "Cannot destroy because position has votes already"
# # end
# #if Position.pluck(:id).vote.count > 0
# unless votes.count.nil?
# self.errors[:base] << "Cannot delete shipment while its invoice exists."
# return false
# # errors.add_to_base("cannot delete")
# # return false
# end
# end
end
class Position < ActiveRecord::Base
has_many :candidates
validates :name, presence: true, uniqueness: true
end
class User < ActiveRecord::Base
GENDER = ["Male", "Female"]
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :votes, :dependent => :restrict_with_error
validates :first_name, presence: true
validates :last_name, presence: true
validates :gender, presence: true
end
class Vote < ActiveRecord::Base
belongs_to :candidate
belongs_to :position
validates :candidate, presence: true
end
<body id="page-top" class="index">
<!-- Navigation -->
<nav id="mainNav" class="navbar navbar-default navbar-custom navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span> Menu <i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top"><%= image_tag("logo.png", :class => "smalllogo")%></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="hidden">
<a href="#page-top"></a>
</li>
<li>
<%= link_to "Home", positions_path, class: "page-scroll" %>
</li>
<li>
<%= link_to "Positions", positions_path, class: "page-scroll" %>
</li>
<li>
<%= link_to "Candidates", candidates_path, class: "page-scroll" %>
</li>
<% if admin_signed_in? %>
<li><%= link_to "Log Out", destroy_admin_session_path, method: :delete %></li>
<% else %>
<li><a class="page-scroll" href="/admin/sign_up">Sign up</a> </li>
<li><a class="page-scroll" href="/admin/sign_in">Login</a> </li>
<% end %>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<br><br><br><br><br><br>
<% if flash[:notice] %>
<p class="notice"><%= flash[:notice] %></p>
<% end %>
<div class="container">
<h2>EDIT CANDIDATE</h2>
</div>
<div class="container">
<%= simple_form_for @candidate, action: :edit, url: "/candidates/update/#{@candidate.id}" do |c| %>
<div class="row">
<%= c.error_notification %>
<%= c.input :first_name, label: "First Name:", error: "Cannot be blank" %>
<%= c.input :last_name, label: "Last Name:", error: "Cannot be blank" %>
<%= c.input :nickname, label: "Nickname:", error: "Cannot be blank" %>
<%= c.input :slogan, label: "Slogan:", error: "Slogan must be unique" %>
<%= c.association :position, label: "Position:", error: "You must choose one" %>
</div>
<br><br><br>
<center>
<%= c.button :submit, "Save", class: "btn btn-conf" %>
<% end %>
<%= link_to "Back", candidates_path, class: "btn btn-conf" %>
</center>
</div>
<br><br><br><br><br><br>
<footer>
<div class="container">
<div class="row">
<div class="col-md-12">
<span class="copyright">Copyright &copy; PHVote 2016</span>
</div>
</div>
</div>
</footer>
</body>
<body id="page-top" class="index">
<!-- Navigation -->
<nav id="mainNav" class="navbar navbar-default navbar-custom navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span> Menu <i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top"><%= image_tag("logo.png", :class => "smalllogo")%></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="hidden">
<a href="#page-top"></a>
</li>
<li>
<%= link_to "Home", positions_path, class: "page-scroll" %>
</li>
<li>
<%= link_to "Positions", positions_path, class: "page-scroll" %>
</li>
<li>
<%= link_to "Candidates", candidates_path, class: "page-scroll" %>
</li>
<% if admin_signed_in? %>
<li><%= link_to "Log Out", destroy_admin_session_path, method: :delete %></li>
<% else %>
<li><a class="page-scroll" href="/admin/sign_up">Sign up</a> </li>
<li><a class="page-scroll" href="/admin/sign_in">Login</a> </li>
<% end %>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<br><br><br><br><br><br>
<% if flash[:notice] %>
<p class="notice"><%= flash[:notice] %></p>
<% end %>
<div class="container">
<h2>CANDIDATES</h2>
</div>
<div class="container">
<table class="table table-hover">
<thead>
<th>
<p><b>First Name</b></p>
</th>
<th>
<p><b>Last Name</b></p>
</th>
<th>
<p><b>Nickname</b></p>
</th>
<th>
<p><b>Slogan</b></p>
</th>
<th>
<p><b>Position I.D.</b></p>
</th>
<th></th>
<th></th>
<th></th>
<th></th>
</thead>
<tbody>
<% @candidates.each do |candidate| %>
<tr>
<td>
<p><%= candidate.first_name %></p>
</td>
<td>
<p><%= candidate.last_name %></p>
</td>
<td>
<p><%= candidate.nickname %></p>
</td>
<td>
<p><%= candidate.slogan %></p>
</td>
<td>
<p><%= candidate.position_id %></p>
</td>
<td></td>
<td>
<p><%= link_to "Show", show_candidate_path(candidate) %></p>
</td>
<td>
<p><%= link_to "Edit", edit_candidate_path(candidate) %></p>
</td>
<td>
<p><%= link_to "Destroy", candidate_path(candidate), method: :delete, data: { confirm: 'Are you sure?'} %></p>
</td>
</tr>
<% end %>
</tbody>
</table>
<center>
<%= link_to "Add Candidate", new_candidate_path, class: "btn btn-conf" %>
</center>
</div>
<br><br><br><br><br><br>
<footer>
<div class="container">
<div class="row">
<div class="col-md-12">
<span class="copyright">Copyright &copy; PHVote 2016</span>
</div>
</div>
</div>
</footer>
</body>
This diff is collapsed.
This diff is collapsed.
<h2>Resend confirmation instructions</h2>
<%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= f.error_notification %>
<%= f.full_error :confirmation_token %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
</div>
<div class="form-actions">
<%= f.button :submit, "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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