Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Final-Elections-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
Christiana Tan
Final-Elections-Project
Commits
e3fdc7e2
Commit
e3fdc7e2
authored
Jul 15, 2016
by
Christiana Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated file
parent
6c386672
Changes
83
Show whitespace changes
Inline
Side-by-side
Showing
83 changed files
with
8949 additions
and
9000 deletions
+8949
-9000
.gitignore
.gitignore
+17
-17
Gemfile
Gemfile
+51
-51
Gemfile.lock
Gemfile.lock
+187
-187
README.rdoc
README.rdoc
+28
-28
Rakefile
Rakefile
+6
-6
application.js
app/assets/javascripts/application.js
+16
-16
candidates.coffee
app/assets/javascripts/candidates.coffee
+3
-3
positions.coffee
app/assets/javascripts/positions.coffee
+3
-3
votes.coffee
app/assets/javascripts/votes.coffee
+3
-0
application.css
app/assets/stylesheets/application.css
+15
-15
bootstrap.css
app/assets/stylesheets/bootstrap.css
+6760
-6760
candidates.scss
app/assets/stylesheets/candidates.scss
+3
-3
positions.scss
app/assets/stylesheets/positions.scss
+3
-3
votes.scss
app/assets/stylesheets/votes.scss
+3
-0
application_controller.rb
app/controllers/application_controller.rb
+5
-5
candidates_controller.rb
app/controllers/candidates_controller.rb
+53
-49
positions_controller.rb
app/controllers/positions_controller.rb
+52
-52
votes_controller.rb
app/controllers/votes_controller.rb
+12
-0
application_helper.rb
app/helpers/application_helper.rb
+2
-2
candidates_helper.rb
app/helpers/candidates_helper.rb
+2
-2
positions_helper.rb
app/helpers/positions_helper.rb
+2
-2
votes_helper.rb
app/helpers/votes_helper.rb
+2
-0
admin.rb
app/models/admin.rb
+6
-6
candidate.rb
app/models/candidate.rb
+10
-10
position.rb
app/models/position.rb
+5
-5
user.rb
app/models/user.rb
+9
-7
vote.rb
app/models/vote.rb
+6
-4
_form.html.erb
app/views/candidates/_form.html.erb
+2
-2
edit.html.erb
app/views/candidates/edit.html.erb
+3
-5
index.html.erb
app/views/candidates/index.html.erb
+28
-54
new.html.erb
app/views/candidates/new.html.erb
+4
-44
show.html.erb
app/views/candidates/show.html.erb
+17
-20
application.html.erb
app/views/layouts/application.html.erb
+47
-46
_form.html.erb
app/views/positions/_form.html.erb
+7
-0
edit.html.erb
app/views/positions/edit.html.erb
+5
-17
index.html.erb
app/views/positions/index.html.erb
+21
-22
new.html.erb
app/views/positions/new.html.erb
+5
-19
show.html.erb
app/views/positions/show.html.erb
+25
-26
index.html.erb
app/views/votes/index.html.erb
+25
-0
voting.html.erb
app/views/votes/voting.html.erb
+6
-0
bundle
bin/bundle
+3
-3
rails
bin/rails
+4
-4
rake
bin/rake
+4
-4
setup
bin/setup
+29
-29
config.ru
config.ru
+4
-4
application.rb
config/application.rb
+26
-26
boot.rb
config/boot.rb
+3
-3
database.yml
config/database.yml
+25
-25
environment.rb
config/environment.rb
+5
-5
development.rb
config/environments/development.rb
+41
-41
production.rb
config/environments/production.rb
+79
-79
test.rb
config/environments/test.rb
+42
-42
assets.rb
config/initializers/assets.rb
+11
-11
backtrace_silencers.rb
config/initializers/backtrace_silencers.rb
+7
-7
cookies_serializer.rb
config/initializers/cookies_serializer.rb
+3
-3
devise.rb
config/initializers/devise.rb
+274
-274
filter_parameter_logging.rb
config/initializers/filter_parameter_logging.rb
+4
-4
inflections.rb
config/initializers/inflections.rb
+16
-16
mime_types.rb
config/initializers/mime_types.rb
+4
-4
session_store.rb
config/initializers/session_store.rb
+3
-3
simple_form.rb
config/initializers/simple_form.rb
+165
-165
simple_form_bootstrap.rb
config/initializers/simple_form_bootstrap.rb
+149
-149
wrap_parameters.rb
config/initializers/wrap_parameters.rb
+14
-14
devise.en.yml
config/locales/devise.en.yml
+62
-62
en.yml
config/locales/en.yml
+23
-23
simple_form.en.yml
config/locales/simple_form.en.yml
+31
-31
routes.rb
config/routes.rb
+14
-40
secrets.yml
config/secrets.yml
+22
-22
20160708033423_create_positions.rb
db/migrate/20160708033423_create_positions.rb
+10
-10
20160708033606_create_candidates.rb
db/migrate/20160708033606_create_candidates.rb
+13
-13
20160711034137_devise_create_admins.rb
db/migrate/20160711034137_devise_create_admins.rb
+42
-42
20160712083205_devise_create_users.rb
db/migrate/20160712083205_devise_create_users.rb
+46
-46
20160712083445_create_votes.rb
db/migrate/20160712083445_create_votes.rb
+11
-11
schema.rb
db/schema.rb
+6
-6
seeds.rb
db/seeds.rb
+7
-7
_form.html.erb
lib/templates/erb/scaffold/_form.html.erb
+13
-13
404.html
public/404.html
+67
-67
422.html
public/422.html
+67
-67
500.html
public/500.html
+66
-66
robots.txt
public/robots.txt
+5
-5
candidates_controller_test.rb
test/controllers/candidates_controller_test.rb
+29
-29
positions_controller_test.rb
test/controllers/positions_controller_test.rb
+34
-34
votes_controller_test.rb
test/controllers/votes_controller_test.rb
+7
-0
No files found.
.gitignore
View file @
e3fdc7e2
Gemfile
View file @
e3fdc7e2
Gemfile.lock
View file @
e3fdc7e2
README.rdoc
View file @
e3fdc7e2
Rakefile
View file @
e3fdc7e2
app/assets/javascripts/application.js
View file @
e3fdc7e2
app/assets/javascripts/candidates.coffee
View file @
e3fdc7e2
app/assets/javascripts/positions.coffee
View file @
e3fdc7e2
app/assets/javascripts/votes.coffee
0 → 100755
View file @
e3fdc7e2
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
app/assets/stylesheets/application.css
View file @
e3fdc7e2
app/assets/stylesheets/bootstrap.css
View file @
e3fdc7e2
app/assets/stylesheets/candidates.scss
View file @
e3fdc7e2
app/assets/stylesheets/positions.scss
View file @
e3fdc7e2
app/assets/stylesheets/votes.scss
0 → 100755
View file @
e3fdc7e2
// 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/
app/controllers/application_controller.rb
View file @
e3fdc7e2
app/controllers/candidates_controller.rb
View file @
e3fdc7e2
class
CandidatesController
<
ApplicationController
before_action
:authenticate_
user!
,
except:
[
:index
]
#or except
before_action
:authenticate_
admin!
,
except:
[
:index
]
def
index
@candidates
=
Candidate
.
all
end
def
vote
end
def
new
@candidate
=
Candidate
.
new
end
...
...
@@ -16,7 +13,7 @@ class CandidatesController < ApplicationController
@candidate
=
Candidate
.
new
(
candidate_params
)
if
@candidate
.
save
redirect_to
candidate
_path
(
@candidate
),
notice:
"User was successfully created"
redirect_to
candidate
s_path
,
notice:
"User was successfully created"
else
render
'new'
end
...
...
@@ -26,7 +23,7 @@ class CandidatesController < ApplicationController
@candidate
=
Candidate
.
find
(
params
[
:id
])
@candidate
.
destroy
()
redirect_to
candidate
_path
redirect_to
candidate
s_path
end
...
...
@@ -35,6 +32,13 @@ class CandidatesController < ApplicationController
end
def
update
@candidate
=
Candidate
.
find
(
params
[
:id
])
if
@candidate
.
update
(
candidate_params
)
redirect_to
candidates_path
else
render
'edit'
end
end
def
show
...
...
app/controllers/positions_controller.rb
View file @
e3fdc7e2
app/controllers/votes_controller.rb
0 → 100755
View file @
e3fdc7e2
class
VotesController
<
ApplicationController
before_action
:authenticate_user!
,
except:
[
:index
]
def
index
@candidates
=
Candidate
.
all
end
def
voting
@vote
=
Vote
.
new
end
end
app/helpers/application_helper.rb
View file @
e3fdc7e2
app/helpers/candidates_helper.rb
View file @
e3fdc7e2
app/helpers/positions_helper.rb
View file @
e3fdc7e2
app/helpers/votes_helper.rb
0 → 100755
View file @
e3fdc7e2
module
VotesHelper
end
app/models/admin.rb
View file @
e3fdc7e2
app/models/candidate.rb
View file @
e3fdc7e2
app/models/position.rb
View file @
e3fdc7e2
app/models/user.rb
View file @
e3fdc7e2
...
...
@@ -4,4 +4,6 @@ class User < ActiveRecord::Base
has_many
:votes
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
end
app/models/vote.rb
View file @
e3fdc7e2
class
Vote
<
ActiveRecord
::
Base
belongs_to
:user_id
belongs_to
:candidate_id
belongs_to
:user
belongs_to
:candidate
validates
:candidate
,
presence:
true
,
uniqueness:
true
end
app/views/candidates/_form.html.erb
View file @
e3fdc7e2
...
...
@@ -4,7 +4,7 @@
<%=
c
.
input
:nickname
%>
<%=
c
.
input
:slogan
,
as: :text
%>
<%=
c
.
association
:position
%>
<%=
c
.
submit
%>
<%=
c
.
button
:submit
,
"Submit"
,
class:
"btn btn-success"
%>
<%=
link_to
'Cancel'
,
candidates_path
,
class:
"btn btn-danger"
%>
<%
end
%>
<%=
link_to
'Cancel'
,
candidates_path
,
class:
"btn btn-danger"
%>
\ No newline at end of file
app/views/candidates/edit.html.erb
View file @
e3fdc7e2
<div
class =
"container"
>
<h1>
Edit Candidate
</h1>
<%=
render
'form'
%>
</div>
\ No newline at end of file
app/views/candidates/index.html.erb
View file @
e3fdc7e2
<div
class =
"container"
>
<%#- <%= current_admin.email %>
<%
@candidates
.
group_by
(
&
:position
).
each
do
|
p
,
can
|
%>
<%
@candidates
.
group_by
(
&
:position
).
each
do
|
p
,
can
|
%>
<h4>
<%=
p
.
name
%>
</h4>
<table
class =
"table"
>
<thead>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Nickname
</th>
<%
if
!
admin_signed_in?
%>
<th>
Votes
</th>
<%
end
%>
<%
if
admin_signed_in?
%>
<th>
Slogan
</th>
<%
end
%>
</thead>
<tbody>
<%
can
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
first_name
%>
</td>
<td>
<%=
c
.
last_name
%>
</td>
<td>
<%=
c
.
nickname
%>
</td>
<%
if
!
admin_signed_in?
%>
<td>
<%=
%>
</td>
<%
end
%>
<%
if
admin_signed_in?
%>
<td>
<%=
c
.
votes
.
count
%>
</td>
<td>
<%=
c
.
slogan
%>
<td>
<%=
link_to
'Show'
,
show_candidates_path
(
c
),
class:
"btn btn-primary"
%>
</td>
<td>
<%=
link_to
'Edit'
,
edit_candidates_path
(
c
),
class:
"btn btn-success"
%>
</td>
<td>
<a
href=
"/candidates/delete?id=
<%=
c
.
id
%>
"
><button
class=
"btn btn-danger"
>
Delete
</button></a></td>
<%
end
%>
<td>
<%=
link_to
'Show'
,
candidate_path
(
c
),
class:
"btn btn-primary"
%>
</td>
<td>
<%=
link_to
'Edit'
,
edit_candidate_path
(
c
),
class:
"btn btn-success"
%>
</td>
<td>
<%=
link_to
'Delete'
,
candidate_path
(
c
),
method: :delete
,
data:
{
confirm:
"Are you sure you want to delete?"
},
class:
"btn btn-danger"
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%
end
%>
<%
if
admin_signed_in?
%>
<%=
link_to
'New Candidate'
,
new_candidates_path
,
class:
"btn btn-primary"
%>
<%
end
%>
<%
if
user_signed_in?
%>
<%=
link_to
'Vote'
,
vote_candidates_path
,
class:
"btn btn-primary"
%>
<%
end
%>
<%
end
%>
<%=
link_to
'New Candidate'
,
new_candidate_path
,
class:
"btn btn-primary"
%>
</div>
\ No newline at end of file
app/views/candidates/new.html.erb
View file @
e3fdc7e2
<h1>
New Candidate
</h1>
<!--
<%=
form_for
(
@candidate
)
do
|
u
|
%>
<%
if
@candidate
.
errors
.
any?
%>
<ul>
<%=
@candidate
.
errors
.
full_messages
.
each
do
|
message
|
%>
<li>
<%=
message
%>
</li>
<%
end
%>
</ul>
<%
end
%>
<p>
<%=
u
.
label
"First Name: "
%>
<%=
u
.
text_field
:first_name
%>
</p>
<p>
<%=
u
.
label
"Last Name: "
%>
<%=
u
.
text_field
:last_name
%>
</p>
<p>
<%=
u
.
label
"Nickname: "
%>
<%=
u
.
text_field
:nickname
%>
</p>
<p>
<%=
u
.
label
"Slogan"
%>
<%=
u
.
text_area
:slogan
%>
<%
if
@candidate
.
errors
.
messages
[
:slogan
].
any?
%>
<%
end
%>
</p>
<button class = "btn btn-success"> Create Candidate
<%
u
.
submit
%>
</button>
<br>
<br>
<%
end
%>
<%=
link_to
'Cancel'
,
candidates_path
,
class:
"btn btn-danger"
%>
-->
<%=
render
'form'
%>
\ No newline at end of file
<div
class =
"container"
>
<h1>
New Candidate
</h1>
<%=
render
'form'
%>
</div>
\ No newline at end of file
app/views/candidates/show.html.erb
View file @
e3fdc7e2
<
h1>
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h1
>
<table
>
<
div
class =
"container"
>
<h1>
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h1>
<table
class =
"table"
>
<thead>
<th>
Nickname
</th>
<th>
Slogan
</th>
<th>
Votes
</th>
</thead>
<tbody>
<tr>
<td>
<%=
@candidate
.
nickname
%>
</td>
<td>
<%=
@candidate
.
slogan
%>
</td>
</tr>
</tbody>
</table>
<%=
link_to
'Back'
,
candidates_path
,
class:
"btn btn-primary"
%>
\ No newline at end of file
</table>
<%=
link_to
'Back'
,
candidates_path
,
class:
"btn btn-primary"
%>
</div>
\ No newline at end of file
app/views/layouts/application.html.erb
View file @
e3fdc7e2
...
...
@@ -15,7 +15,8 @@
</div>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"positions"
>
View Positions
</a></li>
<li>
<%=
link_to
'View Positions'
,
positions_path
%>
</a></li>
<li>
<%=
link_to
'View Candidates'
,
candidates_path
%>
</a></li>
</ul>
...
...
app/views/positions/_form.html.erb
0 → 100755
View file @
e3fdc7e2
<%=
simple_form_for
(
@position
)
do
|
p
|
%>
<%=
p
.
input
:name
%>
<%=
p
.
input
:number_of_winners
%>
<%=
p
.
button
:submit
,
"Submit"
,
class:
"btn btn-success"
%>
<%=
link_to
'Cancel'
,
candidates_path
,
class:
"btn btn-danger"
%>
<%
end
%>
app/views/positions/edit.html.erb
View file @
e3fdc7e2
<h1>
Edit Position
</h1>
<%=
form_for
(
@position
,
url:
update_position_path
(
@position
))
do
|
p
|
%>
<p>
<%=
p
.
label
"Name"
%>
<%=
p
.
text_field
:name
%>
</p>
<div
class =
"container"
>
<h1>
Edit Position
</h1>
s
<p>
<%=
p
.
label
"Number of Winners"
%>
<%=
p
.
text_field
:number_of_winners
%>
</p>
<button
class =
"btn btn-success"
>
Edit position
<%
p
.
submit
%>
</button>
<%
end
%>
<%=
link_to
'Cancel'
,
positions_path
,
class:
"btn btn-danger"
%>
<%=
render
'form'
%>
</div>
\ No newline at end of file
app/views/positions/index.html.erb
View file @
e3fdc7e2
<h1>
List of Positions
</h1>
<table
class =
"table"
>
<div
class =
"container"
>
<h1>
List of Positions
</h1>
<table
class =
"table"
>
<thead>
<th>
Name
</th>
<th>
Number of Winners
</th>
</thead>
<tbody>
<%
@positions
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
name
%>
</td>
<td>
<%=
link_to
'Show'
,
show_position_path
(
c
)
%>
</td>
<td>
<%=
link_to
'Edit'
,
edit_position_path
(
c
)
%>
</td>
<td>
<%=
link_to
'Delete'
,
delete_position_path
(
c
)
%>
</td>
<td>
<%=
c
.
number_of_winners
%>
</td>
<td>
<%=
link_to
'Show'
,
position_path
(
c
),
class:
"btn btn-primary"
%>
</td>
<td>
<%=
link_to
'Edit'
,
edit_position_path
(
c
),
class:
"btn btn-success"
%>
</td>
<td>
<%=
link_to
'Delete'
,
position_path
(
c
),
method: :delete
,
data:
{
confirm:
"Are you sure you want to delete?"
},
class:
"btn btn-danger"
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%=
link_to
'Add new position'
,
new_positions_path
,
class:
"btn btn-primary"
%>
\ No newline at end of file
</table>
<%=
link_to
'Add new position'
,
new_position_path
,
class:
"btn btn-primary"
%>
</div>
\ No newline at end of file
app/views/positions/new.html.erb
View file @
e3fdc7e2
<h1>
New Position
</h1>
<%=
form_for
(
@position
)
do
|
p
|
%>
<p>
<%=
p
.
label
"Name"
%>
<%=
p
.
text_field
:name
%>
</p>
<p>
<%=
p
.
label
"Number of Winners"
%>
<%=
p
.
text_field
:number_of_winners
%>
</p>
<button
class =
"btn btn-success"
>
Create new position
<%
p
.
submit
%>
</button>
<%
end
%>
<%=
link_to
'Cancel'
,
positions_path
,
class:
"btn btn-danger"
%>
<div
class =
"container"
>
<h1>
New Position
</h1>
<%=
render
'form'
%>
</div>
\ No newline at end of file
app/views/positions/show.html.erb
View file @
e3fdc7e2
<h1>
Candidates for
<%=
@position
.
name
%>
</h1>
<div
class =
"container"
>
<h1>
Candidates for
<%=
@position
.
name
%>
</h1>
<table
class =
"table"
>
<table
class =
"table"
>
<thead>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Nickname
</th>
<th>
Slogan
</th>
<th>
Votes
</th>
</thead>
<tbody>
<%
@position
.
candidate
.
each
do
|
c
|
%>
<%
@position
.
candidates
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
first_name
%>
</td>
<td>
<%=
c
.
last_name
%>
</td>
<td>
<%=
c
.
nickname
%>
</td>
<td>
<%=
c
.
slogan
%>
</td>
<td>
<%=
c
.
votes
.
count
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%=
link_to
'Back'
,
positions_path
%>
\ No newline at end of file
</table>
<%=
link_to
'Back'
,
positions_path
,
class:
"btn btn-primary"
%>
</div>
\ No newline at end of file
app/views/votes/index.html.erb
0 → 100755
View file @
e3fdc7e2
<div
class =
"container"
>
<%
@candidates
.
group_by
(
&
:position
).
each
do
|
p
,
can
|
%>
<h4>
<%=
p
.
name
%>
</h4>
<table
class =
"table"
>
<thead>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Nickname
</th>
<th>
Votes
</th>
</thead>
<tbody>
<%
can
.
each
do
|
c
|
%>
<tr>
<td>
<%=
c
.
first_name
%>
</td>
<td>
<%=
c
.
last_name
%>
</td>
<td>
<%=
c
.
nickname
%>
</td>
<td>
<%=
c
.
votes
.
count
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<%
end
%>
<%=
link_to
'Vote'
,
voting_path
,
class:
"btn btn-primary"
%>
</div>
\ No newline at end of file
app/views/votes/voting.html.erb
0 → 100755
View file @
e3fdc7e2
<div
class =
"container"
>
<h1>
Vote for a Candidate
</h1>
<%=
simple_form_for
(
@
)
do
|
c
|
%>
</div>
bin/bundle
View file @
e3fdc7e2
bin/rails
View file @
e3fdc7e2
bin/rake
View file @
e3fdc7e2
bin/setup
View file @
e3fdc7e2
config.ru
View file @
e3fdc7e2
config/application.rb
View file @
e3fdc7e2
config/boot.rb
View file @
e3fdc7e2
config/database.yml
View file @
e3fdc7e2
config/environment.rb
View file @
e3fdc7e2
config/environments/development.rb
View file @
e3fdc7e2
config/environments/production.rb
View file @
e3fdc7e2
config/environments/test.rb
View file @
e3fdc7e2
config/initializers/assets.rb
View file @
e3fdc7e2
config/initializers/backtrace_silencers.rb
View file @
e3fdc7e2
config/initializers/cookies_serializer.rb
View file @
e3fdc7e2
config/initializers/devise.rb
View file @
e3fdc7e2
config/initializers/filter_parameter_logging.rb
View file @
e3fdc7e2
config/initializers/inflections.rb
View file @
e3fdc7e2
config/initializers/mime_types.rb
View file @
e3fdc7e2
config/initializers/session_store.rb
View file @
e3fdc7e2
config/initializers/simple_form.rb
View file @
e3fdc7e2
config/initializers/simple_form_bootstrap.rb
View file @
e3fdc7e2
config/initializers/wrap_parameters.rb
View file @
e3fdc7e2
config/locales/devise.en.yml
View file @
e3fdc7e2
config/locales/en.yml
View file @
e3fdc7e2
config/locales/simple_form.en.yml
View file @
e3fdc7e2
config/routes.rb
View file @
e3fdc7e2
Rails
.
application
.
routes
.
draw
do
resources
:candidates
resources
:positions
devise_for
:users
devise_for
:admins
root
'candidates#index'
get
'/candidates'
,
to:
'candidates#index'
,
as: :candidates
get
'/candidates/new'
,
to:
'candidates#new'
,
as: :new_candidates
get
'/candidates/vote'
,
to:
'candidates#vote'
,
as: :vote_candidates
get
'candidates/edit/:id'
,
to:
'candidates#edit'
,
as: :edit_candidates
get
'/candidates/show/:id'
,
to:
'candidates#show'
,
as: :show_candidates
patch
'candidates/update/:id'
,
to:
'candidates#update'
,
as: :update_candidates
get
'/candidates/delete'
,
to:
'candidates#destroy'
,
as: :delete_candidates
get
'/votes/index'
,
to:
'votes#index'
,
as: :votes
post
'/candidates'
,
to:
'candidates#create'
,
as: :candidate
get
'voting'
,
to:
'votes#voting'
,
as: :voting
root
'votes#index'
get
'positions'
,
to
:'positions#index'
,
as: :positions
get
'positions/new'
,
to
:'positions#new'
,
as: :new_positions
patch
'positions/update/:id'
,
to:
'positions#update'
,
as: :update_position
post
'positions'
,
to:
'positions#create'
,
as: :create_position
get
'positions/edit/:id'
,
to:
'positions#edit'
,
as: :edit_position
get
'positions/show/:id'
,
to:
'positions#show'
,
as: :show_position
get
'/positions/delete/:id'
,
to:
'positions#destroy'
,
as: :delete_position
devise_for
:users
devise_for
:admins
end
config/secrets.yml
View file @
e3fdc7e2
db/migrate/20160708033423_create_positions.rb
View file @
e3fdc7e2
db/migrate/20160708033606_create_candidates.rb
View file @
e3fdc7e2
db/migrate/20160711034137_devise_create_admins.rb
View file @
e3fdc7e2
db/migrate/20160712083205_devise_create_users.rb
View file @
e3fdc7e2
db/migrate/20160712083445_create_votes.rb
View file @
e3fdc7e2
class
CreateVotes
<
ActiveRecord
::
Migration
def
change
create_table
:votes
do
|
t
|
t
.
references
:user
_id
,
index:
true
,
foreign_key:
true
t
.
references
:candidate
_id
,
index:
true
,
foreign_key:
true
t
.
references
:user
,
index:
true
,
foreign_key:
true
t
.
references
:candidate
,
index:
true
,
foreign_key:
true
t
.
text
:comments
t
.
timestamps
null:
false
...
...
db/schema.rb
View file @
e3fdc7e2
...
...
@@ -73,14 +73,14 @@ ActiveRecord::Schema.define(version: 20160712083445) do
add_index
"users"
,
[
"reset_password_token"
],
name:
"index_users_on_reset_password_token"
,
unique:
true
create_table
"votes"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id
_id
"
t
.
integer
"candidate_id
_id
"
t
.
integer
"user_id"
t
.
integer
"candidate_id"
t
.
text
"comments"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
add_index
"votes"
,
[
"candidate_id
_id"
],
name:
"index_votes_on_candidate_id
_id"
add_index
"votes"
,
[
"user_id
_id"
],
name:
"index_votes_on_user_id
_id"
add_index
"votes"
,
[
"candidate_id
"
],
name:
"index_votes_on_candidate
_id"
add_index
"votes"
,
[
"user_id
"
],
name:
"index_votes_on_user
_id"
end
db/seeds.rb
View file @
e3fdc7e2
lib/templates/erb/scaffold/_form.html.erb
View file @
e3fdc7e2
public/404.html
View file @
e3fdc7e2
public/422.html
View file @
e3fdc7e2
public/500.html
View file @
e3fdc7e2
public/robots.txt
View file @
e3fdc7e2
test/controllers/candidates_controller_test.rb
View file @
e3fdc7e2
test/controllers/positions_controller_test.rb
View file @
e3fdc7e2
test/controllers/votes_controller_test.rb
0 → 100755
View file @
e3fdc7e2
require
'test_helper'
class
VotesControllerTest
<
ActionController
::
TestCase
# test "the truth" do
# assert true
# end
end
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