Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MIS21FinalsElection
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
Dean Krisitan Bardeloza
MIS21FinalsElection
Commits
b4c2dc98
Commit
b4c2dc98
authored
Jul 18, 2016
by
Bianca Tarun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added CandidatesController, Vote model, edited Candidate, User, Vote model
parent
23be063f
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
2 deletions
+37
-2
candidates_controller.rb
Election/app/controllers/candidates_controller.rb
+5
-0
candidate.rb
Election/app/models/candidate.rb
+3
-2
user.rb
Election/app/models/user.rb
+1
-0
vote.rb
Election/app/models/vote.rb
+5
-0
20160718023237_create_votes.rb
Election/db/migrate/20160718023237_create_votes.rb
+9
-0
votes.yml
Election/test/fixtures/votes.yml
+7
-0
vote_test.rb
Election/test/models/vote_test.rb
+7
-0
No files found.
Election/app/controllers/candidates_controller.rb
0 → 100644
View file @
b4c2dc98
class
CandidatesController
<
ApplicationController
def
index
@positions
=
Position
.
all
end
end
\ No newline at end of file
Election/app/models/candidate.rb
View file @
b4c2dc98
class
Candidate
<
ActiveRecord
::
Base
class
Candidate
<
ActiveRecord
::
Base
has_many
:votes
validates
:first_name
,
presence:
true
belongs_to
:position
validates
:last_name
,
presence:
true
validates
:slogan
,
uniqueness:
true
,
presence:
true
end
end
Election/app/models/user.rb
View file @
b4c2dc98
...
@@ -3,4 +3,5 @@ class User < ActiveRecord::Base
...
@@ -3,4 +3,5 @@ class User < ActiveRecord::Base
# :confirmable, :lockable, :timeoutable and :omniauthable
# :confirmable, :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
devise
:database_authenticatable
,
:registerable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_many
:votes
end
end
Election/app/models/vote.rb
0 → 100644
View file @
b4c2dc98
class
Vote
<
ActiveRecord
::
Base
belongs_to
:user
belongs_to
:candidate
validates
:candidate_id
,
presence:
true
end
Election/db/migrate/20160718023237_create_votes.rb
0 → 100644
View file @
b4c2dc98
class
CreateVotes
<
ActiveRecord
::
Migration
def
change
create_table
:votes
do
|
t
|
t
.
text
:comments
t
.
timestamps
null:
false
end
end
end
Election/test/fixtures/votes.yml
0 → 100644
View file @
b4c2dc98
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one
:
comments
:
MyText
two
:
comments
:
MyText
Election/test/models/vote_test.rb
0 → 100644
View file @
b4c2dc98
require
'test_helper'
class
VoteTest
<
ActiveSupport
::
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