1
0
Fork 0
forked from OpenNeo/impress

require unique outfit names for each user

This commit is contained in:
Emi Matchu 2010-11-12 21:10:01 -05:00
parent e6b1465355
commit e3ca78203b
2 changed files with 8 additions and 3 deletions

View file

@ -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

View file

@ -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;
}
}