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
94a5cd72
Commit
94a5cd72
authored
Jul 19, 2016
by
Jego Reyes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed the log in page, position and candidate
parent
81edefce
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
89 additions
and
18 deletions
+89
-18
candidates_controller.rb
election_2016/app/controllers/candidates_controller.rb
+9
-0
positions_controller.rb
election_2016/app/controllers/positions_controller.rb
+9
-1
candidate.rb
election_2016/app/models/candidate.rb
+5
-1
position.rb
election_2016/app/models/position.rb
+2
-0
user.rb
election_2016/app/models/user.rb
+4
-2
_form.html.erb
election_2016/app/views/candidates/_form.html.erb
+1
-0
index.html.erb
election_2016/app/views/candidates/index.html.erb
+7
-5
index.html.erb
election_2016/app/views/pages/index.html.erb
+20
-8
profiles.html.erb
election_2016/app/views/pages/profiles.html.erb
+26
-1
edit.html.erb
election_2016/app/views/positions/edit.html.erb
+6
-0
No files found.
election_2016/app/controllers/candidates_controller.rb
View file @
94a5cd72
...
...
@@ -10,6 +10,15 @@ class CandidatesController < ApplicationController
render
"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
end
def
update
@candidate
=
Candidate
.
find
(
params
[
:id
])
...
...
election_2016/app/controllers/positions_controller.rb
View file @
94a5cd72
...
...
@@ -16,7 +16,15 @@ class PositionsController < ApplicationController
if
@position
.
save
redirect_to
position_path
(
@position
.
id
)
else
render
"candidates/new.html.erb"
render
"positions/new.html.erb"
end
end
def
update
if
@poistion
.
update
(
position_params
)
redirect_to
positions_path
else
render
positions_path
end
end
...
...
election_2016/app/models/candidate.rb
View file @
94a5cd72
class
Candidate
<
ActiveRecord
::
Base
belongs_to
:position
validates
:first_name
,
presence:
true
,
uniqueness:
true
validates
:last_name
,
presence:
true
,
uniqueness:
true
validates
:slogan
,
presence:
true
belongs_to
:position
validates
:position
,
presence:
true
end
election_2016/app/models/position.rb
View file @
94a5cd72
class
Position
<
ActiveRecord
::
Base
has_many
:candidates
validates
:name
,
presence:
true
,
uniqueness:
true
end
election_2016/app/models/user.rb
View file @
94a5cd72
class
User
<
ActiveRecord
::
Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
validates
:first_name
,
presence:
true
validates
:last_name
,
presence:
true
validates
:first_name
,
presence:
true
,
uniqueness:
true
validates
:last_name
,
presence:
true
,
uniqueness:
true
validates
:birthday
,
presence:
true
validates
:gender
,
presence:
true
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
...
...
election_2016/app/views/candidates/_form.html.erb
View file @
94a5cd72
<%=
simple_form_for
(
@candidate
)
do
|
c
|
%>
<%=
c
.
input
:id
%>
<%=
c
.
input
:first_name
%>
<%=
c
.
input
:last_name
%>
<%=
c
.
input
:slogan
%>
...
...
election_2016/app/views/candidates/index.html.erb
View file @
94a5cd72
...
...
@@ -12,17 +12,19 @@
<hr>
<%
if
user_signed_in?
%>
Hello
<%=
current_user
.
email
%>
! Your user ID is
<%=
current_user
.
id
%>
.
<h5
style=
"margin-left:50px;"
>
Hello
<%=
current_user
.
email
%>
! Your user ID is
<%=
current_user
.
id
%>
.
</h5>
<hr>
<table
width=
"100%"
>
<table
width=
"100%"
style=
"margin:100px;"
>
<tr>
<th>
Candidate ID
</th>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Slogan
</th>
</tr>
<%
@candidates
.
each
do
|
candidate
|
%>
<tr>
<td>
<%=
candidate
.
id
%>
</td>
<td>
<%=
candidate
.
first_name
%>
</td>
<td>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
slogan
%>
</td>
...
...
@@ -38,7 +40,7 @@
</table>
<br>
<
%=
link_to
"Home"
,
root_path
%
>
<
h4
style=
"margin:100px;"
>
<%=
link_to
"Home"
,
root_path
%>
</h4
>
<%
else
%>
...
...
election_2016/app/views/pages/index.html.erb
View file @
94a5cd72
...
...
@@ -5,7 +5,7 @@
<div
class=
"box fade-in one"
>
<h1
style=
"margin-left:100px;margin-top:
3
00px;font-family:Droid Sans"
>
Election 2016
</h1>
<h1
style=
"margin-left:100px;margin-top:
1
00px;font-family:Droid Sans"
>
Election 2016
</h1>
<h3
style=
"color:#0080ff;margin-left:100px"
>
<%=
link_to
"MIS 21 - B DataBAES"
,
"/about"
%>
...
...
@@ -14,13 +14,8 @@
<h4
style=
"color:#0080ff;margin-left:100px"
>
<%
if
user_signed_in?
%>
Hello
<%=
current_user
.
email
%>
!
<br>
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Profile"
,
"/profiles"
%>
</h4>
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Profile"
,
"/profiles"
%>
<%=
link_to
(
'Log Out'
,
destroy_user_session_path
,
:method
=>
:delete
)
%>
</h4>
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Candidates"
,
candidates_path
%>
</h4>
<h4
style=
"margin-left:100px"
>
<%=
link_to
"Positions"
,
positions_path
%>
</h4>
<h4
style=
"margin-left:100px"
>
<%=
link_to
(
'Log Out'
,
destroy_user_session_path
,
:method
=>
:delete
)
%>
</h4>
<%
else
%>
<h5
style=
"color:#0080ff;margin-left:100px"
>
You're not signed in.
...
...
@@ -31,12 +26,29 @@
</h4>
<table
width=
"100%"
style=
"margin:100px;"
>
<tr>
<th>
Candidate ID
</th>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Slogan
</th>
</tr>
<%
@candidates
.
each
do
|
candidate
|
%>
<tr>
<td>
<%=
candidate
.
id
%>
</td>
<td>
<%=
candidate
.
first_name
%>
</td>
<td>
<%=
candidate
.
last_name
%>
</td>
<td>
<%=
candidate
.
slogan
%>
</td>
</tr>
<%
end
%>
</table>
</div>
</div>
</body>
election_2016/app/views/pages/profiles.html.erb
View file @
94a5cd72
...
...
@@ -2,3 +2,28 @@
<h1>
Election 2016
</h1>
<h3>
Hello
<%=
current_user
.
last_name
%>
</h3>
<table
width=
"100%"
style=
"margin:100px;"
>
<tr>
<th>
Candidate ID
</th>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Slogan
</th>
</tr>
<%
@candidates
.
each
do
|
candidate
|
%>
<tr>
<td>
<%=
candidate
.
id
%>
</td>
<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>
\ No newline at end of file
election_2016/app/views/positions/edit.html.erb
0 → 100644
View file @
94a5cd72
<h1>
Edit Candidate
</h1>
<%=
render
partial:
"form"
%>
<%=
link_to
"Back"
,
positions_path
%>
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