update supported species list on items#show
This commit is contained in:
parent
2486e46a25
commit
f484fc5c21
1 changed files with 5 additions and 1 deletions
|
@ -187,11 +187,15 @@ class Item < ActiveRecord::Base
|
||||||
|
|
||||||
def supported_species
|
def supported_species
|
||||||
body_ids = swf_assets.select([:body_id]).map(&:body_id)
|
body_ids = swf_assets.select([:body_id]).map(&:body_id)
|
||||||
|
|
||||||
return Species.all if body_ids.include?(0)
|
return Species.all if body_ids.include?(0)
|
||||||
|
|
||||||
pet_types = PetType.where(:body_id => body_ids).select([:species_id])
|
pet_types = PetType.where(:body_id => body_ids).select([:species_id])
|
||||||
species_ids = pet_types.map(&:species_id).uniq
|
species_ids = pet_types.map(&:species_id).uniq
|
||||||
Species.find(species_ids)
|
|
||||||
|
# If there are multiple known supported species, it probably supports them
|
||||||
|
# all. (I've never heard of only a handful of species being supported :P)
|
||||||
|
species_ids.size > 1 ? Species.all : Species.find(species_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def support_species?(species)
|
def support_species?(species)
|
||||||
|
|
Loading…
Reference in a new issue