forked from mzslater/learning-rails-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data migration to initialize pages, categories, and links for fresh i…
…nstall
- Loading branch information
1 parent
4a4e60d
commit 9f3b911
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters