Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finalproject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AngKo_Catolico_Ilicito_Reyes
finalproject
Commits
8dd8067c
Commit
8dd8067c
authored
Jul 20, 2016
by
Jarod Christian Catolico
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added changes
parent
c8612200
Changes
35
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
383 additions
and
143 deletions
+383
-143
.DS_Store
election_2016/.DS_Store
+0
-0
.DS_Store
election_2016/app/.DS_Store
+0
-0
candidates_controller.rb
election_2016/app/controllers/admin/candidates_controller.rb
+55
-0
positions_controller.rb
election_2016/app/controllers/admin/positions_controller.rb
+11
-0
candidates_controller.rb
election_2016/app/controllers/candidates_controller.rb
+14
-13
pages_controller.rb
election_2016/app/controllers/pages_controller.rb
+4
-3
positions_controller.rb
election_2016/app/controllers/positions_controller.rb
+2
-41
candidate.rb
election_2016/app/models/candidate.rb
+4
-0
position.rb
election_2016/app/models/position.rb
+2
-2
user.rb
election_2016/app/models/user.rb
+2
-0
vote.rb
election_2016/app/models/vote.rb
+6
-0
.DS_Store
election_2016/app/views/.DS_Store
+0
-0
.DS_Store
election_2016/app/views/admin/.DS_Store
+0
-0
_form.html.erb
election_2016/app/views/admin/candidates/_form.html.erb
+11
-0
edit.html.erb
election_2016/app/views/admin/candidates/edit.html.erb
+9
-0
index.html.erb
election_2016/app/views/admin/candidates/index.html.erb
+45
-0
new.html.erb
election_2016/app/views/admin/candidates/new.html.erb
+8
-0
show.html.erb
election_2016/app/views/admin/candidates/show.html.erb
+18
-0
show.html.erb
election_2016/app/views/admin/positions/show.html.erb
+7
-0
_form.html.erb
election_2016/app/views/candidates/_form.html.erb
+7
-9
edit.html.erb
election_2016/app/views/candidates/edit.html.erb
+1
-4
index.html.erb
election_2016/app/views/candidates/index.html.erb
+13
-34
new.html.erb
election_2016/app/views/candidates/new.html.erb
+1
-4
show.html.erb
election_2016/app/views/candidates/show.html.erb
+9
-13
new.html.erb
election_2016/app/views/devise/confirmations/new.html.erb
+1
-1
new.html.erb
election_2016/app/views/devise/registrations/new.html.erb
+1
-1
application.html.erb
election_2016/app/views/layouts/application.html.erb
+0
-1
index.html.erb
election_2016/app/views/pages/index.html.erb
+13
-1
show.html.erb
election_2016/app/views/positions/show.html.erb
+7
-9
index.html.erb
election_2016/app/views/votes/index.html.erb
+72
-0
vote.html.erb
election_2016/app/views/votes/vote.html.erb
+18
-0
vote_history.html.erb
election_2016/app/views/votes/vote_history.html.erb
+20
-0
routes.rb
election_2016/config/routes.rb
+15
-6
20160720070947_add_more_fields_to_candidates.rb
...b/migrate/20160720070947_add_more_fields_to_candidates.rb
+5
-0
schema.rb
election_2016/db/schema.rb
+2
-1
No files found.
election_2016/.DS_Store
View file @
8dd8067c
No preview for this file type
election_2016/app/.DS_Store
View file @
8dd8067c
No preview for this file type
election_2016/app/controllers/admin/candidates_controller.rb
0 → 100644
View file @
8dd8067c
module
Admin
class
CandidatesController
<
ApplicationController
def
index
@candidates
=
Candidate
.
all
render
"admin/candidates/index.html.erb"
end
def
edit
@candidate
=
Candidate
.
find
(
params
[
:id
])
end
def
update
@candidate
=
Candidate
.
find
(
params
[
:id
])
if
@candidate
.
update
(
candidate_params
())
redirect_to
admin_candidate_path
(
@candidate
.
id
)
else
render
"admin/candidates/edit.html.erb"
end
end
def
new
@candidate
=
Candidate
.
new
render
"admin/candidates/new.html.erb"
end
def
create
@candidate
=
Candidate
.
new
(
candidate_params
())
if
@candidate
.
save
redirect_to
admin_candidate_path
(
@candidate
.
id
)
else
render
"admin/candidates/new.html.erb"
end
end
def
show
@candidate
=
Candidate
.
find
(
params
[
:id
])
render
"admin/candidates/show.html.erb"
end
def
destroy
@candidate
=
Candidate
.
find
(
params
[
:id
])
@candidate
.
destroy!
redirect_to
admin_candidates_path
end
def
candidate_params
params
.
require
(
:candidate
).
permit!
end
end
end
election_2016/app/controllers/admin/positions_controller.rb
0 → 100644
View file @
8dd8067c
module
Admin
class
PositionsController
<
ApplicationController
def
show
@position
=
Position
.
find
(
params
[
:id
])
@candidates
=
@position
.
candidates
render
"admin/positions/show.html.erb"
end
end
end
\ No newline at end of file
election_2016/app/controllers/candidates_controller.rb
View file @
8dd8067c
...
...
@@ -2,36 +2,37 @@ class CandidatesController < ApplicationController
before_action
:authenticate_user!
def
index
@candidates
=
Candidate
.
all
render
"candidates/index.html.erb"
render
"
admin/
candidates/index.html.erb"
end
def
edit
@candidate
=
Candidate
.
find
(
params
[
:id
])
render
"candidates/edit.html.erb"
render
"
admin/
candidates/edit.html.erb"
end
def
create
@candidate
=
Candidate
.
new
(
candidate_params
)
if
@candidate
.
save
redirect_to
candidates_path
else
redirect_to
candidates_path
end
redirect_to
candidate_path
(
@candidate
.
id
)
else
render
"admin/candidates/new.html.erb"
end
end
def
update
@candidate
=
Candidate
.
find
(
params
[
:id
])
if
@candidate
.
update
(
candidate_params
())
redirect_to
candidate_path
(
@candidate
.
id
)
else
render
"
candidates/edit.html.erb"
end
redirect_to
candidate_path
(
@candidate
.
id
)
else
render
"admin/
candidates/edit.html.erb"
end
end
def
new
@candidate
=
Candidate
.
new
render
"candidates/new.html.erb"
render
"
admin/
candidates/new.html.erb"
end
def
create
...
...
@@ -40,13 +41,13 @@ class CandidatesController < ApplicationController
if
@candidate
.
save
redirect_to
candidate_path
(
@candidate
.
id
)
else
render
"candidates/new.html.erb"
render
"
admin/
candidates/new.html.erb"
end
end
def
show
@candidate
=
Candidate
.
find
(
params
[
:id
])
render
"candidates/show.html.erb"
render
"
admin/
candidates/show.html.erb"
end
def
destroy
...
...
election_2016/app/controllers/pages_controller.rb
View file @
8dd8067c
class
PagesController
<
ApplicationController
def
index
def
home
@positions
=
Position
.
all
@users
=
User
.
all
@candidates
=
Candidate
.
all
render
"pages/index.html.erb"
end
def
about
render
"pages/about.html.erb"
end
end
\ No newline at end of file
election_2016/app/controllers/positions_controller.rb
View file @
8dd8067c
class
PositionsController
<
ApplicationController
before_action
:authenticate_user!
def
index
@positions
=
Position
.
all
render
"positions/index.html.erb"
end
def
new
@position
=
Position
.
new
render
"positions/new.html.erb"
end
def
create
@position
=
Position
.
new
(
position_params
())
if
@position
.
save
redirect_to
position_path
(
@position
.
id
)
else
render
"positions/new.html.erb"
end
end
def
update
if
@poistion
.
update
(
position_params
)
redirect_to
positions_path
else
render
positions_path
end
end
def
show
@position
=
Position
.
find
(
params
[
:id
])
render
"positions/show.html.erb"
end
def
destroy
@position
=
Position
.
find
(
params
[
:id
])
@position
.
destroy!
redirect_to
positions_path
end
def
position_params
params
.
require
(
:position
).
permit!
end
@candidates
=
@position
.
candidates
render
"/admin/positions/show.html.erb"
end
election_2016/app/models/candidate.rb
View file @
8dd8067c
...
...
@@ -6,5 +6,9 @@ class Candidate < ActiveRecord::Base
validates
:slogan
,
presence:
true
validates
:position
,
presence:
true
has_many
:votes
def
to_s
"
#{
first_name
}
#{
last_name
}
"
end
end
election_2016/app/models/position.rb
View file @
8dd8067c
class
Position
<
ActiveRecord
::
Base
has_many
:candidates
validates
:name
,
presence:
true
,
uniqueness:
true
has_many
:candidates
end
election_2016/app/models/user.rb
View file @
8dd8067c
...
...
@@ -8,4 +8,6 @@ class User < ActiveRecord::Base
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:votes
end
\ No newline at end of file
election_2016/app/models/vote.rb
View file @
8dd8067c
class
Vote
<
ActiveRecord
::
Base
belongs_to
:candidate
belongs_to
:user
def
to_s
"
#{
first_name
}
"
end
end
election_2016/app/views/.DS_Store
View file @
8dd8067c
No preview for this file type
election_2016/app/views/admin/.DS_Store
0 → 100644
View file @
8dd8067c
File added
election_2016/app/views/admin/candidates/_form.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<%=
simple_form_for
([
:admin
,
@candidate
])
do
|
c
|
%>
<%=
c
.
association
:position
%>
<%=
c
.
input
:first_name
%>
<%=
c
.
input
:last_name
%>
<%=
c
.
input
:nickname
%>
<%=
c
.
input
:slogan
%>
<%=
c
.
submit
%>
<%
end
%>
election_2016/app/views/admin/candidates/edit.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Edit Candidate
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back"
,
admin_candidates_path
%>
election_2016/app/views/admin/candidates/index.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1
style=
"font-family:'Droid Sans';margin-left:50px;margin-top:50px;"
>
Election 2016
</h1>
<h5
style=
"margin-left:50px"
;
>
Candidates
</h5>
<h5>
<%=
link_to
"Add Candidate"
,
new_admin_candidate_path
%>
<hr>
<%
if
user_signed_in?
%>
<h5
style=
"margin-left:50px;"
>
Hello
<%=
current_user
.
email
%>
! Your user ID is
<%=
current_user
.
id
%>
.
</h5>
<hr>
<table
width=
"100%"
style=
"margin:100px;"
>
<tr>
<th>
Position
</th>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Nickname
</th>
<th>
Slogan
</th>
</tr>
<%
@candidates
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
position
.
name
%>
</td>
<td>
<%=
c
.
first_name
%>
</td>
<td>
<%=
c
.
last_name
%>
</td>
<td>
<%=
c
.
nickname
%>
</td>
<td>
<%=
c
.
slogan
%>
</td>
<td>
<%=
link_to
"Show "
,
candidate_path
(
candidate
.
id
)
%>
<%=
link_to
"Edit"
,
edit_admin_candidate_path
(
a
.
id
)
%>
<%=
link_to
"Delete"
,
admin_candidate_path
(
a
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</td>
</tr>
<%
end
%>
</table>
<br>
<h4
style=
"margin:100px;"
>
<%=
link_to
"Home"
,
root_path
%>
</h4>
<%
end
%>
\ No newline at end of file
election_2016/app/views/admin/candidates/new.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
New Candidate
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back"
,
admin_candidates_path
%>
\ No newline at end of file
election_2016/app/views/admin/candidates/show.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h1>
<h3>
<%=
@candidate
.
nickname
%>
</h3>
<br>
<h3>
<u>
Slogan
</u>
<br>
<br>
<h4>
<%=
@candidate
.
slogan
%>
</h4>
</h3>
<hr>
<%=
link_to
"Back to Candidates"
,
admin_candidates_path
%>
\ No newline at end of file
election_2016/app/views/admin/positions/show.html.erb
0 → 100644
View file @
8dd8067c
<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
election_2016/app/views/candidates/_form.html.erb
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<%=
simple_form_for
(
@candidate
)
do
|
c
|
%>
<%=
c
.
input
:id
%>
<%=
c
.
input
:first_name
%>
<%=
c
.
input
:last_name
%>
<%=
c
.
input
:slogan
%>
<%=
c
.
submit
%>
<%=
simple_form_for
(
@candidate
)
do
|
f
|
%>
<%=
f
.
association
:position
%>
<%=
f
.
input
:first_name
%>
<%=
f
.
input
:last_name
%>
<%=
f
.
input
:nickname
%>
<%=
f
.
input
:slogan
%>
<%=
f
.
submit
%>
<%
end
%>
election_2016/app/views/candidates/edit.html.erb
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Edit Candidate
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back"
,
candidates_path
%>
<%=
link_to
"Back
to Candidates
"
,
candidates_path
%>
election_2016/app/views/candidates/index.html.erb
View file @
8dd8067c
<
link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<
h1
style=
"text-align:center"
>
Here are the Candidates
</h1
>
<h1
style=
"font-family:'Droid Sans';margin-left:50px;margin-top:50px;"
>
Election 2016
</h1>
<%=
link_to
"See Total Vote Count"
,
votes_path
%>
<h5
style=
"margin-left:50px"
;
>
<%=
link_to
"Add Position"
,
new_position_path
%>
<%=
link_to
"Add Candidate"
,
new_candidate_path
%>
</h5>
<hr>
<%
if
user_signed_in?
%>
<h5
style=
"margin-left:50px;"
>
Hello
<%=
current_user
.
email
%>
! Your user ID is
<%=
current_user
.
id
%>
.
</h5>
<hr>
<table
width=
"100%"
style=
"margin:100px;"
>
<table
width=
"70%"
,
align=
"center"
>
<tr>
<th>
Candidate ID
</th>
<th>
Position
</th>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Nickname
</th>
<th>
Slogan
</th>
</tr>
<%
@candidates
.
each
do
|
candidate
|
%>
<%
@candidates
.
each
do
|
a
|
%>
<tr>
<td>
<%=
candidate
.
id
%>
</td>
<td>
<%=
candidate
.
first_name
%>
</td>
<td>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
slogan
%>
</td>
<td>
<%=
a
.
position
.
name
%>
</td>
<td>
<%=
a
.
first_name
%>
</td>
<td>
<%=
a
.
last_name
%>
</td>
<td>
<%=
a
.
nickname
%>
</td>
<td>
<%=
a
.
slogan
%>
</td>
<td>
<%=
link_to
"Show "
,
candidate_path
(
candidate
.
id
)
%>
|
<%=
link_to
"Edit"
,
edit_candidate_path
(
candidate
.
id
)
%>
|
<%=
link_to
"Delete"
,
candidate_path
(
candidate
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
<%=
link_to
"Show"
,
candidate_path
(
a
.
id
)
%>
</td>
</tr>
<%
end
%>
</table>
<br>
<h4
style=
"margin:100px;"
>
<%=
link_to
"Home"
,
root_path
%>
</h4>
<%
else
%>
<%
=
link_to
(
"Back to Home"
,
root_path
)
%>
<h3>
You are not signed in. Please
<%=
link_to
"Login"
,
new_user_session_path
%>
</h3>
<%
end
%>
\ No newline at end of file
election_2016/app/views/candidates/new.html.erb
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
New Candidate
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back"
,
candidates_path
%>
\ No newline at end of file
<%=
link_to
"Back to Candidates"
,
candidates_path
%>
election_2016/app/views/candidates/show.html.erb
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h1>
<h3>
<u>
Slogan
</u>
<br>
<br>
<h4>
<%=
@candidate
.
slogan
%>
</h4>
</h3>
<h1>
<%=
@candidate
.
nickname
%>
</h1>
<br>
<ul>
<li>
<%=
@candidate
.
first_name
%>
</li>
<li>
<%=
@candidate
.
last_name
%>
</li>
<li>
<%=
@candidate
.
slogan
%>
</li>
</ul>
<hr>
<%=
link_to
"Back to Candidates"
,
candidates_path
%>
\ No newline at end of file
<%=
link_to
"Back to List"
,
candidates_path
%>
election_2016/app/views/devise/confirmations/new.html.erb
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<link
rel
=
"stylesheet"
type=
"text/css"
href=
"application.css"
>
<h2>
Resend confirmation instructions
</h2>
...
...
election_2016/app/views/devise/registrations/new.html.erb
View file @
8dd8067c
...
...
@@ -10,7 +10,7 @@
<%=
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
,
as: :select
,
:collection
=>
[
'Female'
,
'Male'
]
autofocus:
true
%>
<%=
f
.
input
:gender
,
required:
true
,
as: :select
,
:collection
=>
[
'Female'
,
'Male'
]
,
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
%>
...
...
election_2016/app/views/layouts/application.html.erb
View file @
8dd8067c
...
...
@@ -9,7 +9,6 @@
<body>
<%=
yield
%>
</body>
...
...
election_2016/app/views/pages/index.html.erb
View file @
8dd8067c
...
...
@@ -47,7 +47,19 @@
<%
end
%>
</table>
<%=
link_to
"See Total Vote Count"
,
votes_path
%>
<hr>
<%
@positions
.
each
do
|
c
|
%>
<h2>
(
<%=
c
.
id
%>
)
<%=
c
.
name
%>
</h2>
<ul>
<%
c
.
candidates
.
each
do
|
p
|
%>
<li>
<%=
link_to
p
.
last_name
,
candidate_path
(
p
.
id
)
%>
</li>
<%
end
%>
</ul>
<%=
link_to
"View all candidates"
,
"/positions/
#{
c
.
id
}
"
%>
<%
end
%>
</div>
...
...
election_2016/app/views/positions/show.html.erb
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
<%=
@position
.
name
%>
</h1>
<hr>
<%=
link_to
"Back to 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
election_2016/app/views/votes/index.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<body>
<div
class=
"box fade-in one"
>
<h1
style=
"margin-left:100px;margin-top:100px;font-family:Droid Sans"
>
Election 2016
</h1>
<h3
style=
"color:#0080ff;margin-left:100px"
>
<%=
link_to
"MIS 21 - B DataBAES"
,
"/about"
%>
</h3>
<h4
style=
"color:#0080ff;margin-left:100px"
>
<%
if
user_signed_in?
%>
Hello
<%=
current_user
.
email
%>
!
<br>
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Vote"
,
vote_path
%>
<%=
link_to
"Votes Record"
,
vote_history_path
%>
<%=
link_to
(
"Back to Home"
,
root_path
)
%>
<%=
link_to
(
'Log Out'
,
destroy_user_session_path
,
:method
=>
:delete
)
%>
</h4>
<%
else
%>
<h5
style=
"color:#0080ff;margin-left:100px"
>
You're not signed in.
<%=
link_to
"Login"
,
new_user_session_path
%>
<%=
link_to
"Register"
,
new_user_registration_path
%>
<%=
link_to
"Admin"
,
admin_candidates_path
%>
</h5>
<%
end
%>
</h4>
<table
width=
"100%"
style=
"margin:100px;"
>
<tr>
<th>
Position
</th>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Slogan
</th>
<th>
Number of Votes
</th>
</tr>
<%
@candidates
.
each
do
|
position_id
,
candidates
|
%>
<%=
Position
.
find
(
position_id
).
name
%>
<tr>
<%
candidates
.
each
do
|
candidate
|
%>
</tr>
<tr>
<td>
<%=
candidate
.
position_id
%>
</td>
<td>
<%=
candidate
.
first_name
%>
</td>
<td>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
slogan
%>
</td>
</tr>
<%
end
%>
<%
end
%>
</table>
</div>
</body>
election_2016/app/views/votes/vote.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Ballot
</h1>
<%
@candidates
.
each
do
|
position_id
,
candidates
|
%>
<%=
simple_form_for
(
@vote
,
url:
confirm_vote_path
,
method: :post
)
do
|
o
|
%>
<%=
Position
.
find
(
position_id
).
name
%>
<ul>
<li>
<%=
o
.
association
:candidate
,
:collection
=>
candidates
%>
</li>
<li>
<%=
o
.
input
:comments
%>
</li>
</ul>
<%=
o
.
button
:submit
,
"Vote"
%>
<%
end
%>
<%=
link_to
"Back"
,
candidates_list_path
%>
<%
end
%>
\ No newline at end of file
election_2016/app/views/votes/vote_history.html.erb
0 → 100644
View file @
8dd8067c
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1>
Voting Record of
<%=
current_user
.
first_name
%>
<%=
current_user
.
last_name
%>
</h1>
<table>
<thead>
<th>
Voted Candidate
</th>
<th>
Position
</th>
<th>
Voted On
</th>
</thead>
<tbody>
<%
@votes
.
each
do
|
o
|
%>
<tr>
<td>
<%=
o
.
candidate
.
first_name
%>
&
nbsp
<%=
o
.
candidate
.
last_name
%>
</td>
<td>
<%=
o
.
candidate
.
position
.
name
%>
</td>
<td>
<%=
o
.
created_at
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
election_2016/config/routes.rb
View file @
8dd8067c
Rails
.
application
.
routes
.
draw
do
devise_for
:users
root
to:
"pages#index"
get
"/about"
,
to:
"pages#about"
get
"/votingstatistic"
,
to:
"pages#statistic"
get
"/profiles"
,
to:
"pages#profiles"
root
to:
"votes#index"
get
"/about"
,
to:
"pages#about"
get
"/index"
,
to:
"pages#index"
resources
:candidates
resources
:positions
get
"/positions/:id"
,
to:
"positions#show"
get
'candidates_list'
,
to:
'votes#index'
,
as: :candidates_list
get
'/vote'
,
to:
'votes#vote'
,
as: :vote
post
'/confirm_vote'
,
to:
'votes#confirm_vote'
,
as: :confirm_vote
get
'/vote_history'
,
to:
'votes#vote_history'
,
as: :vote_history
namespace
:admin
do
resources
:candidates
get
"/positions/:id"
,
to:
"positions#show"
end
end
election_2016/db/migrate/20160720070947_add_more_fields_to_candidates.rb
0 → 100644
View file @
8dd8067c
class
AddMoreFieldsToCandidates
<
ActiveRecord
::
Migration
def
change
add_column
:candidates
,
:nickname
,
:string
end
end
election_2016/db/schema.rb
View file @
8dd8067c
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201607
19105648
)
do
ActiveRecord
::
Schema
.
define
(
version:
201607
20070947
)
do
create_table
"candidates"
,
force: :cascade
do
|
t
|
t
.
string
"first_name"
...
...
@@ -20,6 +20,7 @@ ActiveRecord::Schema.define(version: 20160719105648) do
t
.
integer
"position_id"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"nickname"
end
create_table
"positions"
,
force: :cascade
do
|
t
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment