Commit 6a5e4e61ebcd9e29f6e6fe7672eaf574475720ad
1 parent
4324e6fc
Exists in
master
and in
29 other branches
r229@sede: terceiro | 2007-07-28 16:58:00 -0300
ActionItem0: defining acts_as_design class method for ActiveRecord::Base git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@233 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
17 additions
and
0 deletions
Show diff stats
vendor/plugins/design/init.rb
@@ -23,3 +23,20 @@ class ActionController::Base | @@ -23,3 +23,20 @@ class ActionController::Base | ||
23 | end | 23 | end |
24 | 24 | ||
25 | end | 25 | end |
26 | + | ||
27 | +class ActiveRecord::Base | ||
28 | + | ||
29 | + # declares an ActiveRecord class to be a design. The class is automatically | ||
30 | + # associated with a +has_many+ associationto Design::Block. | ||
31 | + # | ||
32 | + # The underlying database table *must* have a column named +design_data+ of | ||
33 | + # type +text+. +string+ should work too, but you may run into problems | ||
34 | + # related to length limit, so unless you have a very good reason not to, use | ||
35 | + # +text+ type. | ||
36 | + def self.acts_as_design | ||
37 | + has_many :boxes, :class_name => 'Design::Box', :as => :owner | ||
38 | + def blocks | ||
39 | + self.boxes.collect{|b| b.blocks}.flatten | ||
40 | + end | ||
41 | + end | ||
42 | +end |