diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index c02e3feb..5e579207 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -25,9 +25,11 @@ class PetType < ActiveRecord::Base } def as_json(options={}) - json = {:id => id, :body_id => body_id} - json[:pet_state_ids] = self.pet_state_ids if options[:for] == 'wardrobe' - json + if options[:for] == 'wardrobe' + {:id => id, :body_id => body_id, :pet_state_ids => pet_state_ids} + else + {:image_hash => image_hash} + end end def color_id=(new_color_id) @@ -59,7 +61,7 @@ class PetType < ActiveRecord::Base end def image_hash - BasicHashes[species.name][color.name] + self['image_hash'] || BasicHashes[species.name][color.name] end def add_pet_state_from_biology!(biology) diff --git a/public/javascripts/outfits/new.js b/public/javascripts/outfits/new.js index 477de0a9..dfe369fc 100644 --- a/public/javascripts/outfits/new.js +++ b/public/javascripts/outfits/new.js @@ -120,11 +120,9 @@ $(function () { name = name.join(' '); Preview.displayLoading(); $.ajax({ - url: '/pet_types.json', + url: '/species/' + type.species + '/color/' + type.color + '/pet_type.json', data: { - 'for': 'image', - 'species_id': type.species, - 'color_id': type.color + 'for': 'image' }, dataType: 'json', success: function (data) {