From b06e8a25c00a500a7f03dab020351623b364daa7 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Wed, 29 May 2024 18:42:41 -0700 Subject: [PATCH] Validate presence of body ID when saving AltStyle This is a minor nbd change, I just noticed when playing around in the console that, unlike most other errors for this model, the `body_id` being required is _only_ enforced in the database schema, so it isn't returned with the usual errors. Not a big deal! Just feels like this is clearer to work with, and more correct to what we *intend*. --- app/models/alt_style.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/alt_style.rb b/app/models/alt_style.rb index 9ebc38e0..aee51809 100644 --- a/app/models/alt_style.rb +++ b/app/models/alt_style.rb @@ -8,6 +8,8 @@ class AltStyle < ApplicationRecord has_many :swf_assets, through: :parent_swf_asset_relationships has_many :contributions, as: :contributed, inverse_of: :contributed + validates :body_id, presence: true + scope :matching_name, ->(series_name, color_name, species_name) { color = Color.find_by_name!(color_name) species = Species.find_by_name!(species_name)