Sha256: ab9b8d3e1e6168ac9580ef6e688e2bf31fa156a9809ba1e400122d47a390ef11
Contents?: true
Size: 1.37 KB
Versions: 9
Compression:
Stored size: 1.37 KB
Contents
require "alchemy/shell" module Alchemy class Seeder extend Alchemy::Shell class << self # This seed builds the necessary page structure for Alchemy in your database. # # Call this from your +db/seeds.rb+ file with the `rake db:seed task'. # def seed! create_default_site create_root_page end protected def create_default_site desc "Creating default Alchemy site" if Alchemy::Site.count == 0 site = Alchemy::Site.new( name: site_config['name'], host: site_config['host'] ) if Alchemy::Language.any? site.languages = Alchemy::Language.all end site.save! log "Created default Alchemy site with default language." else log "Default Alchemy site was already present.", :skip end end def create_root_page desc "Creating Alchemy root page" root = Alchemy::Page.find_or_initialize_by(name: 'Root') root.do_not_sweep = true if root.new_record? if root.save! log "Created Alchemy root page." end else log "Alchemy root page was already present.", :skip end end private def site_config @_site_config ||= Alchemy::Config.get(:default_site) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems