forked from OpenNeo/impress
require unique outfit names for each user
This commit is contained in:
parent
e6b1465355
commit
e3ca78203b
2 changed files with 8 additions and 3 deletions
|
@ -3,7 +3,7 @@ class Outfit < ActiveRecord::Base
|
||||||
belongs_to :pet_state
|
belongs_to :pet_state
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true, :uniqueness => {:scope => :user_id}
|
||||||
validates :pet_state, :presence => true
|
validates :pet_state, :presence => true
|
||||||
|
|
||||||
attr_accessible :name, :pet_state_id, :starred, :unworn_item_ids, :worn_item_ids
|
attr_accessible :name, :pet_state_id, :starred, :unworn_item_ids, :worn_item_ids
|
||||||
|
|
|
@ -590,7 +590,7 @@ View.Outfits = function (wardrobe) {
|
||||||
var SAVE_ERRORS = {
|
var SAVE_ERRORS = {
|
||||||
'item_outfit_relationships': "Item not found. How odd. Pull some items out of your closet and try again.",
|
'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.",
|
'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"
|
'user': "You must be logged in to save outfits"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -611,7 +611,12 @@ View.Outfits = function (wardrobe) {
|
||||||
} else {
|
} else {
|
||||||
for(var key in SAVE_ERRORS) {
|
for(var key in SAVE_ERRORS) {
|
||||||
if(SAVE_ERRORS.hasOwnProperty(key) && typeof errors[key] != 'undefined') {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue