Add page layout support
This commit is contained in:
1 parent
78e8c32969
commit
8dcde174cf
10 files changed
+179
-1
No files matched your search
@@ -0,0 +1,8 @@
|
||||
class Layout < CouchFoo::Base
|
||||
|
||||
property :name, String
|
||||
property :content, String
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
end
|
||||
@@ -3,7 +3,21 @@ class Page < CouchFoo::Base
|
||||
property :name, String
|
||||
property :parent_name, String
|
||||
property :content, String
|
||||
property :layout_id, String
|
||||
property :layout_name, String
|
||||
|
||||
belongs_to :layout
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
before_save :setup_layout_id
|
||||
|
||||
def setup_layout_id
|
||||
if self.layout_name.blank?
|
||||
self.layout_id = nil
|
||||
else
|
||||
self.layout_id = Layout.find_by_name( self.layout_name ).id
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user