Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Site < ActiveRecord::Base
- has_many :pages
- after_create :setup
- def setup
- homepage = Page.from_yaml(YAML.load_file(RAILS_ROOT+'/lib/flower/default_homepage.yml'))
- self.pages << homepage
- homepage.publish!
- end
- end
- class Page < ActiveRecord::Base
- belongs_to :site
- has_many :blocks, :as => :container, :dependent => :destroy, :order => 'position ASC', :extend => Container
- class << self
- def from_yaml(values={})
- p = Page.new(:title => values['title'], :slug => values['slug'])
- if hsh['blocks']
- !! p.blocks = values['blocks'].collect {|block| Block.from_yaml(block) }
- end
- return p
- end
- end
- end
- class Block < ActiveRecord::Base
- belongs_to :container, :polymorphic => true
- validates_presence_of :container
- end
- !! >> s = Site.create(:domain => 'fqdn.com')
Add Comment
Please, Sign In to add comment