diff --git a/app/models/outfit.rb b/app/models/outfit.rb index 2911f3af..edad2a0b 100644 --- a/app/models/outfit.rb +++ b/app/models/outfit.rb @@ -3,7 +3,7 @@ class Outfit < ActiveRecord::Base belongs_to :pet_state belongs_to :user - validates :name, :presence => true + validates :name, :presence => true, :uniqueness => {:scope => :user_id} validates :pet_state, :presence => true attr_accessible :name, :pet_state_id, :starred, :unworn_item_ids, :worn_item_ids diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index 08a5ea5c..72251a9a 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -590,7 +590,7 @@ View.Outfits = function (wardrobe) { var SAVE_ERRORS = { 'item_outfit_relationships': "Item not found. How odd. Pull some items out of your closet and try again.", 'pet_state': "Pet state not found. How odd. Try picking a new Gender/Emotion.", - 'name': "Outfits must have a name", + 'name': true, 'user': "You must be logged in to save outfits" }; @@ -611,7 +611,12 @@ View.Outfits = function (wardrobe) { } else { for(var key in SAVE_ERRORS) { if(SAVE_ERRORS.hasOwnProperty(key) && typeof errors[key] != 'undefined') { - saveErrorMessage(SAVE_ERRORS[key]); + var message = SAVE_ERRORS[key]; + if(message === true) { + message = key.charAt(0).toUpperCase() + key.substr(1) + ' ' + + errors[key]; + } + saveErrorMessage(message); break; } }