check uniqueness for item, layout and snippet
This commit is contained in:
parent
3d6446041b
commit
e11dc5dd83
|
@ -15,6 +15,8 @@ class Item
|
|||
key :is_published, Boolean, :required => true, :default => true, :index => true
|
||||
|
||||
validates_format_of :name, :with => /^[a-zA-Z-_]+$/
|
||||
validates_uniqueness_of :name
|
||||
|
||||
belongs_to :parent, :class_name => "Item", :foreign_key => :parent_id
|
||||
many :children, :class_name => "Item", :foreign_key => :parent_id, :dependent => :destroy
|
||||
|
||||
|
|
|
@ -9,5 +9,6 @@ class Layout
|
|||
many :children, :class_name => "Item", :foreign_key => "layout_id", :dependent => :nullify
|
||||
|
||||
validates_format_of :name, :with => /^[a-zA-Z-_]+$/
|
||||
validates_uniqueness_of :name
|
||||
|
||||
end
|
|
@ -4,11 +4,12 @@ class Snippet
|
|||
|
||||
key :name, String, :required => true, :index => true
|
||||
key :parent_name, String, :required => true, :index => true
|
||||
key :parent_id, String, :required => true, :index => true
|
||||
key :parent_id, ObjectId, :required => true, :index => true
|
||||
|
||||
key_i18n :content, String
|
||||
|
||||
before_validation :setup_default_value
|
||||
validates_uniqueness_of :name, :scope => :parent_id
|
||||
|
||||
protected
|
||||
|
||||
|
|
Reference in New Issue