update supported species list on items#show

This commit is contained in:
Emi Matchu 2013-01-28 16:54:25 -06:00
parent 2486e46a25
commit f484fc5c21

View file

@ -187,11 +187,15 @@ class Item < ActiveRecord::Base
def supported_species
body_ids = swf_assets.select([:body_id]).map(&:body_id)
return Species.all if body_ids.include?(0)
pet_types = PetType.where(:body_id => body_ids).select([:species_id])
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
def support_species?(species)