about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-09-23 10:30:23 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-09-23 10:30:23 -0400
commitf6cdc2fd2f50224fb7dd31d3ccb374cf4ffe7b6d (patch)
tree460dae3bae5a4ac961e6db0d9ca5c2b99bbdca0e /app/models
parent1d621019d7bf74b65898e009aef31766c7e7572b (diff)
downloadpokeviewer-f6cdc2fd2f50224fb7dd31d3ccb374cf4ffe7b6d.tar.gz
pokeviewer-f6cdc2fd2f50224fb7dd31d3ccb374cf4ffe7b6d.tar.bz2
pokeviewer-f6cdc2fd2f50224fb7dd31d3ccb374cf4ffe7b6d.zip
Moved revision moves into revision table
This is a retroactive schema change, so there's no easy way to migrate
into it without losing data, but this is so early into the development
of this project that it really doesn't matter.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/pokeviewer/revision.rb33
-rw-r--r--app/models/pokeviewer/revision_move.rb19
2 files changed, 29 insertions, 23 deletions
diff --git a/app/models/pokeviewer/revision.rb b/app/models/pokeviewer/revision.rb index a8f8ab2..9d1ddf4 100644 --- a/app/models/pokeviewer/revision.rb +++ b/app/models/pokeviewer/revision.rb
@@ -3,10 +3,6 @@ module Pokeviewer
3 belongs_to :pokemon 3 belongs_to :pokemon
4 acts_as_sequenced scope: :pokemon_id 4 acts_as_sequenced scope: :pokemon_id
5 5
6 has_many :revision_moves, -> { order "number ASC" }
7 has_many :moves, through: :revision_moves
8
9 validates :moves, presence: true
10 validates :nickname, presence: true 6 validates :nickname, presence: true
11 7
12 validates :experience, presence: true, 8 validates :experience, presence: true,
@@ -68,5 +64,34 @@ module Pokeviewer
68 greater_than_or_equal_to: 0, 64 greater_than_or_equal_to: 0,
69 less_than_or_equal_to: 10, 65 less_than_or_equal_to: 10,
70 only_integer: true } 66 only_integer: true }
67
68 belongs_to :move_1, class_name: "Move"
69 belongs_to :move_2, class_name: "Move", optional: true
70 belongs_to :move_3, class_name: "Move", optional: true
71 belongs_to :move_4, class_name: "Move", optional: true
72
73 validates :move_1_pp_bonuses, presence: true,
74 numericality: {
75 greater_than_or_equal_to: 0,
76 less_than_or_equal_to: 3,
77 only_integer: true}
78
79 validates :move_2_pp_bonuses, presence: true,
80 numericality: {
81 greater_than_or_equal_to: 0,
82 less_than_or_equal_to: 3,
83 only_integer: true}
84
85 validates :move_3_pp_bonuses, presence: true,
86 numericality: {
87 greater_than_or_equal_to: 0,
88 less_than_or_equal_to: 3,
89 only_integer: true}
90
91 validates :move_4_pp_bonuses, presence: true,
92 numericality: {
93 greater_than_or_equal_to: 0,
94 less_than_or_equal_to: 3,
95 only_integer: true}
71 end 96 end
72end 97end
diff --git a/app/models/pokeviewer/revision_move.rb b/app/models/pokeviewer/revision_move.rb deleted file mode 100644 index 74b9e9e..0000000 --- a/app/models/pokeviewer/revision_move.rb +++ /dev/null
@@ -1,19 +0,0 @@
1module Pokeviewer
2 class RevisionMove < ApplicationRecord
3 belongs_to :revision
4 belongs_to :move
5
6 validates :number, presence: true,
7 numericality: {
8 greater_than_or_equal_to: 1,
9 less_than_or_equal_to: 4,
10 only_integer: true },
11 uniqueness: { scope: :revision_id }
12
13 validates :pp_bonuses, presence: true,
14 numericality: {
15 greater_than_or_equal_to: 0,
16 less_than_or_equal_to: 3,
17 only_integer: true}
18 end
19end