diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/pokedex_entry.rb | 7 | ||||
-rw-r--r-- | app/models/pokemon.rb | 2 | ||||
-rw-r--r-- | app/models/run.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 3 |
4 files changed, 12 insertions, 1 deletions
diff --git a/app/models/pokedex_entry.rb b/app/models/pokedex_entry.rb new file mode 100644 index 0000000..21924ce --- /dev/null +++ b/app/models/pokedex_entry.rb @@ -0,0 +1,7 @@ +class PokedexEntry < ApplicationRecord + belongs_to :user + belongs_to :run + belongs_to :pokemon + + validates :recorded_at, presence: true +end diff --git a/app/models/pokemon.rb b/app/models/pokemon.rb index 7543f64..293281a 100644 --- a/app/models/pokemon.rb +++ b/app/models/pokemon.rb @@ -1,3 +1,5 @@ class Pokemon < ApplicationRecord + has_many :pokedex_entries, dependent: :restrict_with_error + validates :pokedex_num, :name, presence: true end diff --git a/app/models/run.rb b/app/models/run.rb index a763654..472e8c7 100644 --- a/app/models/run.rb +++ b/app/models/run.rb @@ -2,6 +2,7 @@ class Run < ApplicationRecord belongs_to :game belongs_to :user has_many :checkpoints, dependent: :destroy + has_many :pokedex_entries, dependent: :destroy validates :title, presence: true diff --git a/app/models/user.rb b/app/models/user.rb index 27ff9b2..ed3f425 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,6 +3,7 @@ class User < ApplicationRecord # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :rememberable - has_many :runs, dependent: :restrict_with_error has_many :checkpoints, through: :runs + has_many :pokedex_entries, dependent: :destroy + has_many :runs, dependent: :restrict_with_error end |