public
Description: Sample application for the Learning Rails free online course in Ruby on Rails
Homepage: http://www.learningrails.com
Clone URL: git://github.com/mzslater/learning-rails-sample-app.git
learning-rails-sample-app / db / migrate / 011_default_pages.rb
100644 55 lines (45 sloc) 2.808 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class DefaultPages < ActiveRecord::Migration
  def self.up
    if Page.find(:all).empty?
      Page.create(:name => 'home', :title => 'Learning Rails Sample Application Home', :navlabel => 'Home', :position => 1,
        :admin => false, :redirect => false,
        :body => 'h1. Welcome to the Learning Rails Sample Application')
      about_page = Page.create(:name => 'about', :title => 'About the Learning Rails Sample Application', :navlabel => 'About', :position => 2,
        :admin => false, :redirect => false,
        :body => 'h1. About This Application
p. This is the sample application for the "Learning Rails" free online course.
For more information, see "LearningRails.com":http://learningrails.com')
      Page.create(:name => 'resources', :title => 'Learning Rails Resources', :navlabel => 'Resources', :position => 3,
        :admin => false, :redirect => true,
        :action_name => 'list', :controller_name => 'links')
      Page.create(:name => 'contact', :title => 'Contact Us', :navlabel => 'Contact', :position => 4,
        :admin => false, :redirect => true,
        :action_name => 'new', :controller_name => 'messages')
      Page.create(:name => 'admin', :title => 'Sample App Administration', :navlabel => 'Admin', :position => 9,
        :admin => true, :redirect => false,
        :body => 'h1. Admin Dashboard
 
p. "Page Admin":/pages
 
p. "User Admin":/users
 
p. "Category Admin":/categories
 
p. "Link Admin":/links
 
p. "Message Admin":/messages')
      Page.create(:name => 'services', :title => 'Services', :navlabel => 'Services', :position => 1,
        :admin => false, :redirect => false, :parent => about_page,
        :body => 'h1. Services
p. This page is here just to illustrate a subpage')
      Page.create(:name => 'products', :title => 'Products', :navlabel => 'Products', :position => 2,
        :admin => false, :redirect => false, :parent => about_page,
        :body => 'h1. Products
p. This page is here just to illustrate a subpage')
    end
    if Category.find(:all).empty?
      rails_resources = Category.create(:title => 'Rails Resources', :description => 'Resources for Rails Developers')
      html_resources = Category.create(:title => 'HTML Resources', :description => 'Basic HTML Resources')
      Link.create(:url => 'http://www.buildingwebapps.com', :title => 'BuildingWebApps.com', :description => 'Resource site for
web application developers, created by the authors of the Learning Rails course').categories << rails_resources
      Link.create(:url => 'http://w3c.org', :title => 'W3C', :description => 'Official standards body for the web').categories << html_resources
    end
  end
 
  def self.down
  end
end