forked from OpenNeo/impress
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*.
This commit is contained in:
parent
c78d51ab01
commit
b06e8a25c0
1 changed files with 2 additions and 0 deletions
|
@ -8,6 +8,8 @@ class AltStyle < ApplicationRecord
|
||||||
has_many :swf_assets, through: :parent_swf_asset_relationships
|
has_many :swf_assets, through: :parent_swf_asset_relationships
|
||||||
has_many :contributions, as: :contributed, inverse_of: :contributed
|
has_many :contributions, as: :contributed, inverse_of: :contributed
|
||||||
|
|
||||||
|
validates :body_id, presence: true
|
||||||
|
|
||||||
scope :matching_name, ->(series_name, color_name, species_name) {
|
scope :matching_name, ->(series_name, color_name, species_name) {
|
||||||
color = Color.find_by_name!(color_name)
|
color = Color.find_by_name!(color_name)
|
||||||
species = Species.find_by_name!(species_name)
|
species = Species.find_by_name!(species_name)
|
||||||
|
|
Loading…
Reference in a new issue