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
b131b536
Commit
b131b536
authored
Jul 18, 2016
by
Bianca Tarun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edited models and added foreign keys
parent
aa32fd71
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
5 deletions
+30
-5
candidate.rb
Election/app/models/candidate.rb
+2
-0
20160718030435_add_user_to_votes.rb
Election/db/migrate/20160718030435_add_user_to_votes.rb
+5
-0
20160718031224_add_candidate_to_votes.rb
Election/db/migrate/20160718031224_add_candidate_to_votes.rb
+5
-0
20160718031721_add_candidate_to_positions.rb
...n/db/migrate/20160718031721_add_candidate_to_positions.rb
+5
-0
schema.rb
Election/db/schema.rb
+13
-5
No files found.
Election/app/models/candidate.rb
View file @
b131b536
...
@@ -2,4 +2,6 @@ class Candidate < ActiveRecord::Base
...
@@ -2,4 +2,6 @@ class Candidate < ActiveRecord::Base
validates
:first_name
,
presence:
true
validates
:first_name
,
presence:
true
validates
:last_name
,
presence:
true
validates
:last_name
,
presence:
true
validates
:slogan
,
uniqueness:
true
,
presence:
true
validates
:slogan
,
uniqueness:
true
,
presence:
true
belongs_to
:position
has_many
:votes
end
end
Election/db/migrate/20160718030435_add_user_to_votes.rb
0 → 100644
View file @
b131b536
class
AddUserToVotes
<
ActiveRecord
::
Migration
def
change
add_reference
:votes
,
:user
,
index:
true
,
foreign_key:
true
end
end
Election/db/migrate/20160718031224_add_candidate_to_votes.rb
0 → 100644
View file @
b131b536
class
AddCandidateToVotes
<
ActiveRecord
::
Migration
def
change
add_reference
:votes
,
:candidate
,
index:
true
,
foreign_key:
true
end
end
Election/db/migrate/20160718031721_add_candidate_to_positions.rb
0 → 100644
View file @
b131b536
class
AddCandidateToPositions
<
ActiveRecord
::
Migration
def
change
add_reference
:positions
,
:candidate
,
index:
true
,
foreign_key:
true
end
end
Election/db/schema.rb
View file @
b131b536
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201607180
23237
)
do
ActiveRecord
::
Schema
.
define
(
version:
201607180
31721
)
do
create_table
"candidates"
,
force: :cascade
do
|
t
|
create_table
"candidates"
,
force: :cascade
do
|
t
|
t
.
string
"first_name"
t
.
string
"first_name"
...
@@ -27,8 +27,11 @@ ActiveRecord::Schema.define(version: 20160718023237) do
...
@@ -27,8 +27,11 @@ ActiveRecord::Schema.define(version: 20160718023237) do
t
.
string
"name"
t
.
string
"name"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"candidate_id"
end
end
add_index
"positions"
,
[
"candidate_id"
],
name:
"index_positions_on_candidate_id"
create_table
"users"
,
force: :cascade
do
|
t
|
create_table
"users"
,
force: :cascade
do
|
t
|
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
...
@@ -51,6 +54,11 @@ ActiveRecord::Schema.define(version: 20160718023237) do
...
@@ -51,6 +54,11 @@ ActiveRecord::Schema.define(version: 20160718023237) do
t
.
text
"comments"
t
.
text
"comments"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
integer
"user_id"
t
.
integer
"candidate_id"
end
end
add_index
"votes"
,
[
"candidate_id"
],
name:
"index_votes_on_candidate_id"
add_index
"votes"
,
[
"user_id"
],
name:
"index_votes_on_user_id"
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