Modification of the page model

This commit is contained in:
chris2tof committed 2011-05-18 10:00:00 +08:00
1 parent 4399804e19
commit 3d97c5bfda
9 files changed
+71 -36

No files matched your search

+16 -15
View File
@@ -1,20 +1,21 @@
class Layout
include Mongoid::Document
include Mongoid::Document
include Mongoid::Timestamps
field :name, :index => true
field :description
field :content
references_many :children, :class_name => "Item"
validates_presence_of :name
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
validates_uniqueness_of :name
def self.exist_one?
Layout.count > 0
end
field :name, :index => true
field :description
field :content
references_many :children, :class_name => "Item"
has_many :layout_parts
validates_presence_of :name
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
validates_uniqueness_of :name
def self.exist_one?
Layout.count > 0
end
end
+11
View File
@@ -0,0 +1,11 @@
class LayoutPart
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :content
belongs_to :layout
end
+1
View File
@@ -9,6 +9,7 @@ class Page < Item
validates_presence_of :layout_name, :layout_id
referenced_in :layout
has_many :page_parts
protected
+11
View File
@@ -0,0 +1,11 @@
class PagePart
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :content
belongs_to :page
end