From 3d6446041bdb94476e83c8adc42f3d58953ab520 Mon Sep 17 00:00:00 2001 From: Wen-Tien Chang Date: Fri, 5 Feb 2010 16:59:41 +0800 Subject: [PATCH] handle destroy layout --- app/models/layout.rb | 2 ++ lib/tasks/dev.rake | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/layout.rb b/app/models/layout.rb index 10693f26..b22a3c67 100644 --- a/app/models/layout.rb +++ b/app/models/layout.rb @@ -6,6 +6,8 @@ class Layout key :description, String key_i18n :content, String + many :children, :class_name => "Item", :foreign_key => "layout_id", :dependent => :nullify + validates_format_of :name, :with => /^[a-zA-Z-_]+$/ end \ No newline at end of file diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index a18a5d99..01244b36 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -2,7 +2,7 @@ namespace :dev do task :build => :environment do [Announcement, Item, Snippet, Layout].each { |m| m.delete_all } - Layout.create!( :name => 'root', :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.layout.zh_tw").read, + Layout.create!( :name => 'root', :description => 'root', :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.layout.zh_tw").read, :content_en => File.open("#{RAILS_ROOT}/lib/template/root.layout.en").read) Page.create!( :name => "root", :title => I18n.t(:homepage), :layout_name => "root", :parent_name => nil,