add series= setter for weapon, include flags in series list
This commit is contained in:
parent
38f126f2ef
commit
f64fd63b6c
2 changed files with 12 additions and 4 deletions
|
|
@ -10,12 +10,10 @@ module Api
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
fields :slug, :order
|
fields :slug, :order, :extra, :element_changeable, :has_weapon_keys,
|
||||||
|
:has_awakening, :has_ax_skills
|
||||||
|
|
||||||
view :full do
|
view :full do
|
||||||
fields :extra, :element_changeable, :has_weapon_keys,
|
|
||||||
:has_awakening, :has_ax_skills
|
|
||||||
|
|
||||||
field :weapon_count do |ws|
|
field :weapon_count do |ws|
|
||||||
ws.weapons.count
|
ws.weapons.count
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -156,4 +156,14 @@ class Weapon < ApplicationRecord
|
||||||
def series_slug
|
def series_slug
|
||||||
weapon_series&.slug || SERIES_SLUGS[series]
|
weapon_series&.slug || SERIES_SLUGS[series]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Virtual attribute to set weapon_series by ID or slug
|
||||||
|
# Supports both UUID and slug lookup for flexibility
|
||||||
|
def series=(value)
|
||||||
|
return self.weapon_series = nil if value.blank?
|
||||||
|
|
||||||
|
# Try to find by ID first, then by slug
|
||||||
|
found = WeaponSeries.find_by(id: value) || WeaponSeries.find_by(slug: value)
|
||||||
|
self.weapon_series = found
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue