Skip to content

Commit

Permalink
Data migration to initialize pages, categories, and links for fresh i…
Browse files Browse the repository at this point in the history
…nstall
  • Loading branch information
michael-slater committed Aug 31, 2008
1 parent 4a4e60d commit 9f3b911
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
54 changes: 54 additions & 0 deletions db/migrate/011_default_pages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 10) do
ActiveRecord::Schema.define(:version => 11) do

create_table "categories", :force => true do |t|
t.string "title"
Expand Down

0 comments on commit 9f3b911

Please sign in to comment.