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
0a0c9184
Commit
0a0c9184
authored
Jul 17, 2016
by
Jarod Christian Catolico
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed add candidate, show, edit, delete; Initially fixed add position
parent
70646218
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
176 additions
and
45 deletions
+176
-45
Gemfile.lock
election_2016/Gemfile.lock
+8
-0
candidates_controller.rb
election_2016/app/controllers/candidates_controller.rb
+19
-18
positions_controller.rb
election_2016/app/controllers/positions_controller.rb
+28
-2
position.rb
election_2016/app/models/position.rb
+1
-0
index.html.erb
election_2016/app/views/candidates/index.html.erb
+39
-10
new.html.erb
election_2016/app/views/candidates/new.html.erb
+1
-1
show.html.erb
election_2016/app/views/candidates/show.html.erb
+10
-2
about.html.erb
election_2016/app/views/pages/about.html.erb
+4
-4
index.html.erb
election_2016/app/views/pages/index.html.erb
+4
-5
_form.html.erb
election_2016/app/views/positions/_form.html.erb
+4
-0
index.html.erb
election_2016/app/views/positions/index.html.erb
+46
-0
new.html.erb
election_2016/app/views/positions/new.html.erb
+5
-0
show.html.erb
election_2016/app/views/positions/show.html.erb
+6
-0
routes.rb
election_2016/config/routes.rb
+1
-3
No files found.
election_2016/Gemfile.lock
View file @
0a0c9184
...
@@ -38,6 +38,7 @@ GEM
...
@@ -38,6 +38,7 @@ GEM
tzinfo (~> 1.1)
tzinfo (~> 1.1)
arel (6.0.3)
arel (6.0.3)
bcrypt (3.1.11)
bcrypt (3.1.11)
bcrypt (3.1.11-x86-mingw32)
binding_of_caller (0.7.2)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
debug_inspector (>= 0.0.1)
builder (3.2.2)
builder (3.2.2)
...
@@ -83,6 +84,9 @@ GEM
...
@@ -83,6 +84,9 @@ GEM
nokogiri (1.6.8)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
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)
orm_adapter (0.5.0)
pkg-config (1.1.7)
pkg-config (1.1.7)
rack (1.6.4)
rack (1.6.4)
...
@@ -139,6 +143,7 @@ GEM
...
@@ -139,6 +143,7 @@ GEM
activesupport (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
sqlite3 (1.3.11)
sqlite3 (1.3.11-x86-mingw32)
thor (0.19.1)
thor (0.19.1)
thread_safe (0.3.5)
thread_safe (0.3.5)
tilt (2.0.5)
tilt (2.0.5)
...
@@ -147,6 +152,8 @@ GEM
...
@@ -147,6 +152,8 @@ GEM
turbolinks-source (5.0.0)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
tzinfo (1.2.2)
thread_safe (~> 0.1)
thread_safe (~> 0.1)
tzinfo-data (1.2016.6)
tzinfo (>= 1.0.0)
uglifier (3.0.0)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
execjs (>= 0.3.0, < 3)
warden (1.2.6)
warden (1.2.6)
...
@@ -159,6 +166,7 @@ GEM
...
@@ -159,6 +166,7 @@ GEM
PLATFORMS
PLATFORMS
ruby
ruby
x86-mingw32
DEPENDENCIES
DEPENDENCIES
byebug
byebug
...
...
election_2016/app/controllers/candidates_controller.rb
View file @
0a0c9184
...
@@ -5,18 +5,29 @@ class CandidatesController < ApplicationController
...
@@ -5,18 +5,29 @@ class CandidatesController < ApplicationController
render
"candidates/index.html.erb"
render
"candidates/index.html.erb"
end
end
def
show
def
edit
@candidate
=
Candidate
.
all
@candidate
=
Candidate
.
find
(
params
[
:id
])
render
"candidates/
show
.html.erb"
render
"candidates/
edit
.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
end
def
new
def
new
@candidate
=
Candidate
.
all
@candidate
=
Candidate
.
new
render
"candidates/new.html.erb"
render
"candidates/new.html.erb"
end
end
def
create
def
create
@candidate
=
Candidate
.
all
@candidate
=
Candidate
.
new
(
candidate_params
())
if
@candidate
.
save
if
@candidate
.
save
redirect_to
candidate_path
(
@candidate
.
id
)
redirect_to
candidate_path
(
@candidate
.
id
)
else
else
...
@@ -24,28 +35,18 @@ class CandidatesController < ApplicationController
...
@@ -24,28 +35,18 @@ class CandidatesController < ApplicationController
end
end
end
end
def
edit
def
show
@candidate
=
Candidate
.
find
(
params
[
:id
])
render
"posts/edit.html.erb"
end
def
update
@candidate
=
Candidate
.
find
(
params
[
:id
])
@candidate
=
Candidate
.
find
(
params
[
:id
])
if
@candidate
.
update
(
candidate_params
)
render
"candidates/show.html.erb"
redirect_to
candidate_path
(
@candidate
.
id
)
else
render
"candidates/edit.html.erb"
end
end
end
def
destroy
def
destroy
@candidate
=
Candidate
.
find
(
params
[
:id
])
@candidate
=
Candidate
.
find
(
params
[
:id
])
@
post
.
destroy!
@
candidate
.
destroy!
redirect_to
candidates_path
redirect_to
candidates_path
end
end
def
candidate_params
def
candidate_params
params
.
require
(
:candidate
).
permit!
params
.
require
(
:candidate
).
permit!
end
end
end
end
\ No newline at end of file
election_2016/app/controllers/positions_controller.rb
View file @
0a0c9184
...
@@ -2,10 +2,36 @@ class PositionsController < ApplicationController
...
@@ -2,10 +2,36 @@ class PositionsController < ApplicationController
before_action
:authenticate_user!
before_action
:authenticate_user!
def
index
def
index
@positions
=
Position
.
all
@positions
=
Position
.
all
render
"position/index.html.erb"
render
"position
s
/index.html.erb"
end
end
def
new
def
new
@position
=
Position
.
all
@position
=
Position
.
new
render
"positions/new.html.erb"
render
"positions/new.html.erb"
end
end
def
create
@position
=
Position
.
new
(
position_params
())
if
@position
.
save
redirect_to
position_path
(
@position
.
id
)
else
render
"candidates/new.html.erb"
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
end
end
election_2016/app/models/position.rb
View file @
0a0c9184
class
Position
<
ActiveRecord
::
Base
class
Position
<
ActiveRecord
::
Base
has_many
:candidates
end
end
election_2016/app/views/candidates/index.html.erb
View file @
0a0c9184
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<link
rel
"
stylesheet
"
type=
"text/css"
href=
"application.css"
>
<h1
style=
"font-family:'Droid Sans';margin-left:50px;margin-top:50px;"
>
Election 2016
</h1>
<h1
style=
"font-family:'Droid Sans';margin-left:50px;margin-top:50px;"
>
Election 2016
</h1>
<h5
style=
"margin-left:50px"
;
>
<h5
style=
"margin-left:50px"
;
>
<%=
link_to
"Add Position"
,
new_position_path
%>
<%=
link_to
"Add Position"
,
new_position_path
%>
<%=
link_to
"Add Candidate"
,
new_candidate_path
%>
<%=
link_to
"Add Candidate"
,
new_candidate_path
%>
</h5>
</h5>
<hr>
<hr>
<!--
<%=
link_to
"Add Candidate"
,
new_candidate_path
%>
-->
<%
if
user_signed_in?
%>
<!--
<%=
link_to
"Edit Candidate"
,
"/candidates/:id/edit"
%>
-->
Hello
<%=
current_user
.
email
%>
! Your user ID is
<%=
current_user
.
id
%>
.
<!--
<%=
link_to
"Delete Candidate"
,
"/candidates/:id"
,
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
-->
<hr>
<table
width=
"100%"
>
<tr>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Slogan
</th>
</tr>
<%
@candidates
.
each
do
|
candidate
|
%>
<tr>
<td>
<%=
candidate
.
first_name
%>
</td>
<td>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
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?'
}
%>
</td>
</tr>
<%
end
%>
</table>
<br>
<%=
link_to
"Home"
,
root_path
%>
<!--
<%
if
user_signed_in?
%>
Hello User!
<%
else
%>
<%
else
%>
You are not signed in. Please go to login page.
<%
end
%>
-->
<h3>
\ No newline at end of file
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 @
0a0c9184
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
<%=
render
partial:
"form"
%>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back"
,
candidates_path
%>
<%=
link_to
"Back"
,
candidates_path
%>
\ No newline at end of file
election_2016/app/views/candidates/show.html.erb
View file @
0a0c9184
<h1>
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h1>
<h1>
<h3>
<%=
@candidate
.
slogan
%>
</h3>
<%=
@candidate
.
first_name
%>
<%=
@candidate
.
last_name
%>
</h1>
<h3>
<u>
Slogan
</u>
<br>
<br>
<h4>
<%=
@candidate
.
slogan
%>
</h4>
</h3>
<hr>
<hr>
<%=
link_to
"Back to Candidates"
,
candidates_path
%>
<%=
link_to
"Back to Candidates"
,
candidates_path
%>
\ No newline at end of file
election_2016/app/views/pages/about.html.erb
View file @
0a0c9184
...
@@ -9,13 +9,13 @@
...
@@ -9,13 +9,13 @@
<h6
style=
"margin-left:100px"
>
<h6
style=
"margin-left:100px"
>
<li
style=
"margin-top:10px"
>
Troy Ang Ko
</li>
<li
style=
"margin-top:10px"
>
Troy Ang Ko
</li>
<p
style=
"color:#66ccff;margin-top:10px; margin-left: 50px;"
>
The mala
ndi
</p>
<p
style=
"color:#66ccff;margin-top:10px; margin-left: 50px;"
>
The mala
kas sa chicks
</p>
<li
style=
"margin-top:10px"
>
Jarod Catolico
</li>
<li
style=
"margin-top:10px"
>
Jarod Catolico
</li>
<p
style=
"color:#4dc3ff;margin-top:10px; margin-left: 50px;"
>
The ma
s malandi
</p>
<p
style=
"color:#4dc3ff;margin-top:10px; margin-left: 50px;"
>
The ma
lakas sa chicken
</p>
<li
style=
"margin-top:10px"
>
Norence Ilicito
</li>
<li
style=
"margin-top:10px"
>
Norence Ilicito
</li>
<p
style=
"color:#33bbff;margin-top:10px; margin-left: 50px;"
>
The sketchy
</p>
<p
style=
"color:#33bbff;margin-top:10px; margin-left: 50px;"
>
The sketchy
CSS Master
</p>
<li
style=
"margin-top:10px"
>
Jego Reyes
</li>
<li
style=
"margin-top:10px"
>
Jego Reyes
</li>
<p
style=
"color:#1ab2ff;margin-top:10px; margin-left: 50px;"
>
The pogi
</p>
<p
style=
"color:#1ab2ff;margin-top:10px; margin-left: 50px;"
>
The pogi
pero malandi
</p>
</h6>
</h6>
<h3
style=
"margin-left:100px"
>
<%=
link_to
"Back"
,
".."
%>
</h3>
<h3
style=
"margin-left:100px"
>
<%=
link_to
"Back"
,
".."
%>
</h3>
...
...
election_2016/app/views/pages/index.html.erb
View file @
0a0c9184
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
<h4
style=
"color:#0080ff;margin-left:100px"
>
<h4
style=
"color:#0080ff;margin-left:100px"
>
<%
if
user_signed_in?
%>
<%
if
user_signed_in?
%>
Hello
<%=
current_user
.
email
%>
!
Hello
<%=
current_user
.
email
%>
!
<br>
<%=
link_to
(
'Log Out'
,
destroy_user_session_path
,
:method
=>
:delete
)
%>
<%=
link_to
(
'Log Out'
,
destroy_user_session_path
,
:method
=>
:delete
)
%>
<%
else
%>
<%
else
%>
<h5
style=
"color:#0080ff;margin-left:100px"
>
<h5
style=
"color:#0080ff;margin-left:100px"
>
...
@@ -27,11 +28,9 @@
...
@@ -27,11 +28,9 @@
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Candidates"
,
candidates_path
%>
</h4>
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Candidates"
,
candidates_path
%>
</h4>
</div>
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Positions"
,
positions_path
%>
</h4>
</div>
</body>
</body>
election_2016/app/views/positions/_form.html.erb
0 → 100644
View file @
0a0c9184
<%=
simple_form_for
(
@position
)
do
|
p
|
%>
<%=
p
.
input
:name
,
as: :select
,
collection:
[
"President"
,
"Vice President"
,
"Senator"
]
%>
<%=
p
.
submit
%>
<%
end
%>
election_2016/app/views/positions/index.html.erb
0 → 100644
View file @
0a0c9184
<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"
;
>
<%=
link_to
"Add Position"
,
new_position_path
%>
<%=
link_to
"Add Candidate"
,
new_candidate_path
%>
</h5>
<hr>
<%
if
user_signed_in?
%>
Hello
<%=
current_user
.
email
%>
! Your user ID is
<%=
current_user
.
id
%>
.
<hr>
<table
width=
"100%"
>
<tr>
<th>
Position
</th>
</tr>
<%
@positions
.
each
do
|
position
|
%>
<tr>
<td>
<%=
position
.
name
%>
</td>
<td>
<%=
link_to
"Show "
,
position_path
(
position
.
id
)
%>
|
<%=
link_to
"Edit"
,
edit_position_path
(
position
.
id
)
%>
|
<%=
link_to
"Delete"
,
position_path
(
position
.
id
),
method: :delete
,
data:
{
confirm:
'Are you sure?'
}
%>
</td>
</tr>
<%
end
%>
</table>
<br>
<%=
link_to
"Go to Candidates"
,
candidates_path
%>
|
<%=
link_to
"Home"
,
root_path
%>
<%
else
%>
<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/positions/new.html.erb
0 → 100644
View file @
0a0c9184
<h1>
Add Position
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back"
,
candidates_path
%>
\ No newline at end of file
election_2016/app/views/positions/show.html.erb
0 → 100644
View file @
0a0c9184
<h1>
<%=
@position
.
name
%>
</h1>
<hr>
<%=
link_to
"Back to Candidates"
,
candidates_path
%>
\ No newline at end of file
election_2016/config/routes.rb
View file @
0a0c9184
Rails
.
application
.
routes
.
draw
do
Rails
.
application
.
routes
.
draw
do
devise_for
:users
devise_for
:users
root
to:
"pages#index"
root
to:
"pages#index"
get
"/about"
,
to:
"pages#about"
resources
:candidates
resources
:candidates
get
"/about"
,
to:
"pages#about"
resources
:positions
resources
:positions
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