From f6cdc2fd2f50224fb7dd31d3ccb374cf4ffe7b6d Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 23 Sep 2017 10:30:23 -0400 Subject: 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. --- app/models/pokeviewer/revision.rb | 33 +++++++++++++++++++++++++++++---- app/models/pokeviewer/revision_move.rb | 19 ------------------- 2 files changed, 29 insertions(+), 23 deletions(-) delete mode 100644 app/models/pokeviewer/revision_move.rb (limited to 'app/models') 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 belongs_to :pokemon acts_as_sequenced scope: :pokemon_id - has_many :revision_moves, -> { order "number ASC" } - has_many :moves, through: :revision_moves - - validates :moves, presence: true validates :nickname, presence: true validates :experience, presence: true, @@ -68,5 +64,34 @@ module Pokeviewer greater_than_or_equal_to: 0, less_than_or_equal_to: 10, only_integer: true } + + belongs_to :move_1, class_name: "Move" + belongs_to :move_2, class_name: "Move", optional: true + belongs_to :move_3, class_name: "Move", optional: true + belongs_to :move_4, class_name: "Move", optional: true + + validates :move_1_pp_bonuses, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 3, + only_integer: true} + + validates :move_2_pp_bonuses, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 3, + only_integer: true} + + validates :move_3_pp_bonuses, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 3, + only_integer: true} + + validates :move_4_pp_bonuses, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 3, + only_integer: true} end 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 @@ -module Pokeviewer - class RevisionMove < ApplicationRecord - belongs_to :revision - belongs_to :move - - validates :number, presence: true, - numericality: { - greater_than_or_equal_to: 1, - less_than_or_equal_to: 4, - only_integer: true }, - uniqueness: { scope: :revision_id } - - validates :pp_bonuses, presence: true, - numericality: { - greater_than_or_equal_to: 0, - less_than_or_equal_to: 3, - only_integer: true} - end -end -- cgit 1.4.1