module ActsAsLayoutable class AreaBuilder < ActsAsLayoutable::Builder def method_missing(meth, *args, &block) self.item = ActsAsLayoutable::Area.create!(:name => meth.to_s) args.each do |widget| self.item.widgets << ActsAsLayoutable::Widget.find_or_create_by_name(widget.to_s) end self.collection << self.item self.item.save self.item end end class Area < ActiveRecord::Base belongs_to :layout has_many :widgets end end