namespace :dev do task :build => :environment do User.delete_all User.create!( :email => 'ihower@rulingcom.com', :password => 'password', :password_confirmation => 'password', :use_attributes => ["teacher"] ) UserAttribute.create!( :ident => "teacher", :name => "Teacher", :attrs => [ "name" => { :type => 'text_field', :width => 100 }, "title" => { :type => 'text_field', :width => 100 } ] ) [Announcement, Item, Snippet, Layout].each { |m| m.delete_all } Layout.create!( :name => 'root', :description => 'root', :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.layout.zh_tw").read, :content_en => File.open("#{RAILS_ROOT}/lib/template/root.layout.en").read) Page.create!( :name => "root", :title => I18n.t(:homepage), :layout_name => "root", :parent_name => nil, :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/root.page.zh_tw").read, :content_en => File.open("#{RAILS_ROOT}/lib/template/root.page.en").read ) ["about"].each do |page_name| Page.create!( :name => page_name, :title => page_name, :layout_name => "root", :parent_name => "root", :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.page.zh_tw").read, :content_en => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.page.en").read ) end ["nav", "footer", "locale"].each do |page_name| Snippet.create!( :name => page_name, :parent_name => "root", :content_zh_tw => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.snippet.zh_tw").read, :content_en => File.open("#{RAILS_ROOT}/lib/template/#{page_name}.snippet.en").read ) end end end