004_add_sidebars.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:2k
源码类别:

Ajax

开发平台:

Others

  1. class Bare4Sidebar < ActiveRecord::Base
  2.   include BareMigration
  3.   # there's technically no need for these serialize declaration because in
  4.   # this script active_config and staged_config will always be NULL anyway.
  5.   serialize :active_config
  6.   serialize :staged_config
  7. end
  8. class AddSidebars < ActiveRecord::Migration
  9.   def self.up
  10.     STDERR.puts "Creating sidebars"
  11.     Bare4Sidebar.transaction do
  12.       create_table :sidebars do |t|
  13.         t.column :controller, :string
  14.         t.column :active_position, :integer
  15.         t.column :active_config, :text
  16.         t.column :staged_position, :integer
  17.         t.column :staged_config, :text
  18.       end
  19.       Bare4Sidebar.create(:active_position=>0, :controller=>'page', :active_config=>'--- !map:HashWithIndifferentAccess 
  20.       maximum_pages: "10"')
  21.       Bare4Sidebar.create(:active_position=>1, :controller=>'category', :active_config=>'--- !map:HashWithIndifferentAccess 
  22.       empty: false
  23.       count: true')
  24.       Bare4Sidebar.create(:active_position=>2, :controller=>'archives', :active_config=>'--- !map:HashWithIndifferentAccess 
  25.       show_count: true
  26.       count: "10"')
  27.       Bare4Sidebar.create(:active_position=>3, :controller=>'static', :active_config=>'--- !map:HashWithIndifferentAccess 
  28.       title: Links
  29.       body: |+
  30.       <ul>
  31.         <li><a href="http://www.typosphere.org" title="Typo">Typosphere</a></li>
  32.         <li><a href="http://typogarden.org">Typogarden</a></li>
  33.         <li><a href="http://www.bofh.org.uk" title="Just a Summary">Just A Summary</a></li>
  34.         <li><a href="http://fredericdevillamil.com" title="Frédéric de Villamil">Ergonomie, Rails et bonnes pratiques du web</a></li>
  35.         <li><a href="/admin">Admin</a></li>
  36.       </ul>'
  37.       )
  38.       Bare4Sidebar.create(:active_position=>4, :controller=>'xml', :active_config=>'--- !map:HashWithIndifferentAccess 
  39.       format: rss20
  40.       trackbacks: true
  41.       comments: true
  42.       articles: true')
  43.     end
  44.   end
  45.   def self.down
  46.     drop_table :sidebars
  47.   end
  48. end