Skip to content

Instantly share code, notes, and snippets.

@wnstn
Created May 8, 2012 20:01
Show Gist options
  • Save wnstn/2638882 to your computer and use it in GitHub Desktop.
Save wnstn/2638882 to your computer and use it in GitHub Desktop.
class AddAcademyFacultyPage < ActiveRecord::Migration
def self.up
site = Site.find_by_subdomain('academy')
aboutpage = site.pages.find_by_slug('about')
page = site.pages.find_by_slug('about-faculty')
aboutpage.children << page
1.upto(4) do |i|
tab = ContainerWidget.create!(:name => "tab_#{i}", :title => 'Tab Title')
tab.children << SimpleHtmlWidget.create!(:name => "body", :text => "Copy about Academy Staff, requirements, or whatever you want to say. Phasellus in massa. Curabitur dolor eros, gravida et, hendrerit ac, cursus non, massa. Aliquam lorem. In hac habitasse platea dictumst. Cras eu mauris.")
10.times do |j|
tab.children << ImageWidget.create!(:name => "faculty_#{j}", :title => "Faculty Member #{j}", :text => "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", :collapsible => true, :collapsed => true, :width => 100, :height => 100)
end
page.widgets << tab
end
end
def self.down
site = Site.find_by_subdomain('academy')
aboutpage = site.pages.find_by_slug('about')
page = site.pages.find_by_slug('about-faculty')
1.upto(4) do |i|
page.widgets.find_by_name("tab_#{i}").destroy
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment