diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/pokeviewer/revision.rb | 33 | ||||
-rw-r--r-- | app/models/pokeviewer/revision_move.rb | 19 |
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 |
72 | end | 97 | end |
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 @@ | |||
1 | module 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 | ||
19 | end | ||