Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
final_project
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
evilla_gomez_guian_principe
final_project
Commits
6eaa926e
Commit
6eaa926e
authored
Jul 21, 2016
by
April Guian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a
parent
7d42009a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
1 deletion
+36
-1
election_controller.rb
Halalan-FINAL/app/controllers/election_controller.rb
+31
-0
votes_controller.rb
Halalan-FINAL/app/controllers/voting/votes_controller.rb
+1
-1
show.html.erb
Halalan-FINAL/app/views/admin/candidates/show.html.erb
+3
-0
routes.rb
Halalan-FINAL/config/routes.rb
+1
-0
No files found.
Halalan-FINAL/app/controllers/election_controller.rb
0 → 100644
View file @
6eaa926e
class
ElectionController
<
ApplicationController
before_action
:authenticate_user!
def
vote
@positions
=
Position
.
all
@position
=
Position
.
find
(
params
[
:id
])
@candidates
=
Candidate
.
all
@votes
=
Vote
.
all
voted_for
=
false
@position
.
candidates
.
each
do
|
c
|
c
.
votes
.
each
do
|
v
|
if
current_user
.
id
==
v
.
user_id
voted_for
=
true
end
end
end
if
voted_for
==
false
redirect_to
new_voting_vote_path
else
redirect_to
voting_votes_path
end
end
def
vote_params
params
.
require
(
:vote
).
permit!
end
end
\ No newline at end of file
Halalan-FINAL/app/controllers/voting/votes_controller.rb
View file @
6eaa926e
...
...
@@ -26,7 +26,7 @@ module Voting
voted_for
=
false
@pos
=
params
[
:id
]
Position
.
find
(
@pos
).
candidates
.
each
do
|
c
|
Position
.
find
(
@pos
).
candidates
.
each
do
|
c
|
c
.
votes
.
each
do
|
v
|
if
current_user
.
id
==
v
.
user_id
voted_for
=
true
...
...
Halalan-FINAL/app/views/admin/candidates/show.html.erb
View file @
6eaa926e
...
...
@@ -23,6 +23,9 @@
<div
class=
"btn btn-info"
role =
"button"
>
<%=
link_to
"Delete"
,
admin_candidate_path
(
@candidate
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</div>
<div
class=
"btn btn-info"
role =
"button"
>
<%=
link_to
"Vote"
,
election_vote_path
(
@candidate
.
id
)
%>
</div>
<h2>
<%=
@candidate
.
position
.
name
%>
</h2>
<br>
...
...
Halalan-FINAL/config/routes.rb
View file @
6eaa926e
...
...
@@ -5,6 +5,7 @@ Rails.application.routes.draw do
get
"/profile"
,
to:
"users/users#index"
get
"/voting/new/:id"
,
to:
"voting/votes#new"
get
"/election/vote/:id"
,
to:
"election#vote"
,
as: :election_vote
get
"/about"
=>
"pages#about"
,
as: :about
get
"/about/evilla"
,
to:
"about#evilla"
...
...
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