From 6a5e4e61ebcd9e29f6e6fe7672eaf574475720ad Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Tue, 31 Jul 2007 13:03:33 +0000 Subject: [PATCH] r229@sede: terceiro | 2007-07-28 16:58:00 -0300 ActionItem0: defining acts_as_design class method for ActiveRecord::Base --- vendor/plugins/design/init.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+), 0 deletions(-) diff --git a/vendor/plugins/design/init.rb b/vendor/plugins/design/init.rb index 353ef4f..a51b0c0 100644 --- a/vendor/plugins/design/init.rb +++ b/vendor/plugins/design/init.rb @@ -23,3 +23,20 @@ class ActionController::Base end end + +class ActiveRecord::Base + + # declares an ActiveRecord class to be a design. The class is automatically + # associated with a +has_many+ associationto Design::Block. + # + # The underlying database table *must* have a column named +design_data+ of + # type +text+. +string+ should work too, but you may run into problems + # related to length limit, so unless you have a very good reason not to, use + # +text+ type. + def self.acts_as_design + has_many :boxes, :class_name => 'Design::Box', :as => :owner + def blocks + self.boxes.collect{|b| b.blocks}.flatten + end + end +end -- libgit2 0.21.2