Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.

Commit 3509d10

Browse files
authored
Merge pull request #19 from GraphQLAcademy/add-film-associations-2
Add Film associations to models
2 parents b55d2ef + ae80426 commit 3509d10

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

app/models/person.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ class Person < ApplicationRecord
44

55
has_and_belongs_to_many :starships
66
has_and_belongs_to_many :vehicles
7+
has_and_belongs_to_many :films
78
end

app/models/planet.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class Planet < ApplicationRecord
22
has_many :residents, class_name: 'Person', foreign_key: 'homeworld_id'
3+
has_and_belongs_to_many :films
34
end

app/models/species.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class Species < ApplicationRecord
22
belongs_to :homeworld, class_name: 'Planet'
33
has_many :people
4+
has_and_belongs_to_many :films
45
end

app/models/vehicle.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ class Vehicle < ApplicationRecord
44
join_table: 'people_vehicles',
55
foreign_key: 'vehicle_id',
66
association_foreign_key: 'person_id'
7+
has_and_belongs_to_many :films
78
end

0 commit comments

Comments
 (0)