Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CI320
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wellington Gabriel Vicente de Souza
CI320
Commits
57b6f101
Commit
57b6f101
authored
7 years ago
by
Wellington Gabriel Vicente de Souza
Browse files
Options
Downloads
Patches
Plain Diff
add working model relationships and destroy methods
parent
168b5706
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
T2/models.rb
+11
-4
11 additions, 4 deletions
T2/models.rb
T2/schema.rb
+2
-2
2 additions, 2 deletions
T2/schema.rb
T2/steamdb.rb
+455
-326
455 additions, 326 deletions
T2/steamdb.rb
with
468 additions
and
332 deletions
T2/models.rb
+
11
−
4
View file @
57b6f101
...
...
@@ -4,13 +4,14 @@ ActiveRecord::Base.establish_connection :adapter => "sqlite3",
:database
=>
"steamdb.sqlite3"
class
Game
<
ActiveRecord
::
Base
;
has_one
:price
has_one
:price
,
dependent: :destroy
belongs_to
:developer
has_and_belongs_to_many
:categories
has_many
:category_games
has_many
:categories
,
through: :category_games
,
dependent: :destroy
end
class
Developer
<
ActiveRecord
::
Base
;
has_many
:games
has_many
:games
,
dependent: :destroy
end
class
Price
<
ActiveRecord
::
Base
;
...
...
@@ -18,5 +19,11 @@ class Price < ActiveRecord::Base;
end
class
Category
<
ActiveRecord
::
Base
;
has_and_belongs_to_many
:games
has_many
:category_games
has_many
:games
,
through: :category_games
,
dependent: :destroy
end
class
CategoryGame
<
ActiveRecord
::
Base
;
belongs_to
:category
belongs_to
:game
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
T2/schema.rb
+
2
−
2
View file @
57b6f101
...
...
@@ -28,7 +28,7 @@ ActiveRecord::Base.connection.create_table :categories do |t|
t
.
text
:description
end
ActiveRecord
::
Base
.
connection
.
create_table
:categor
ies
_games
,
id:
false
do
|
t
|
ActiveRecord
::
Base
.
connection
.
create_table
:categor
y
_games
,
id:
false
do
|
t
|
t
.
references
:category
t
.
references
:game
end
\ No newline at end of file
end
This diff is collapsed.
Click to expand it.
T2/steamdb.rb
+
455
−
326
View file @
57b6f101
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment