创建作品分类表,并插入部分数据

This commit is contained in:
sw 2014-07-19 11:35:43 +08:00
parent 9fe4c9f8a2
commit 79c76d26c8
6 changed files with 132 additions and 2 deletions

View File

@ -0,0 +1,3 @@
class WorksCategory < ActiveRecord::Base
attr_accessible :category
end

View File

@ -0,0 +1,9 @@
class CreateWorksCategories < ActiveRecord::Migration
def change
create_table :works_categories do |t|
t.string :category
t.timestamps
end
end
end

View File

@ -0,0 +1,98 @@
# -*coding:utf-8 -*-
class SetWorksCategories < ActiveRecord::Migration
def up
workscategory1 = WorksCategory.new
workscategory1.category = "影音播放"
workscategory1.save
workscategory2 = WorksCategory.new
workscategory2.category = "交通导航"
workscategory2.save
workscategory3 = WorksCategory.new
workscategory3.category = "生活娱乐"
workscategory3.save
workscategory4 = WorksCategory.new
workscategory4.category = "网络购物"
workscategory4.save
workscategory5 = WorksCategory.new
workscategory5.category = "输入法"
workscategory5.save
workscategory6 = WorksCategory.new
workscategory6.category = "聊天社区"
workscategory6.save
workscategory7 = WorksCategory.new
workscategory7.category = "浏览器"
workscategory7.save
workscategory8 = WorksCategory.new
workscategory8.category = "窗口小部件"
workscategory8.save
workscategory9 = WorksCategory.new
workscategory9.category = "安全防护"
workscategory9.save
workscategory10 = WorksCategory.new
workscategory10.category = "拍照摄影"
workscategory10.save
workscategory11 = WorksCategory.new
workscategory11.category = "实用工具"
workscategory11.save
workscategory12 = WorksCategory.new
workscategory12.category = "词典翻译"
workscategory12.save
workscategory13 = WorksCategory.new
workscategory13.category = "教育阅读"
workscategory13.save
workscategory14 = WorksCategory.new
workscategory14.category = "主题桌面"
workscategory14.save
workscategory15 = WorksCategory.new
workscategory15.category = "事务管理"
workscategory15.save
workscategory16 = WorksCategory.new
workscategory16.category = "系统工具"
workscategory16.save
workscategory17 = WorksCategory.new
workscategory17.category = "资讯新闻"
workscategory17.save
workscategory18 = WorksCategory.new
workscategory18.category = "金融理财"
workscategory18.save
workscategory19 = WorksCategory.new
workscategory19.category = "通话通信"
workscategory19.save
workscategory20 = WorksCategory.new
workscategory20.category = "电子办公"
workscategory20.save
workscategory21 = WorksCategory.new
workscategory21.category = "体育竞技"
workscategory21.save
workscategory22 = WorksCategory.new
workscategory22.category = "健康医疗"
workscategory22.save
end
def down
WorksCategory.all do |wc|
wc.destroy
end
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140716021558) do ActiveRecord::Schema.define(:version => 20140719030941) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -916,7 +916,7 @@ ActiveRecord::Schema.define(:version => 20140716021558) do
create_table "softapplications", :force => true do |t| create_table "softapplications", :force => true do |t|
t.string "name" t.string "name"
t.string "description" t.text "description"
t.integer "app_type_id" t.integer "app_type_id"
t.string "app_type_name" t.string "app_type_name"
t.string "android_min_version_available" t.string "android_min_version_available"
@ -1212,4 +1212,10 @@ ActiveRecord::Schema.define(:version => 20140716021558) do
add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status"
add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id"
create_table "works_categories", :force => true do |t|
t.string "category"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end end

7
test/fixtures/works_categories.yml vendored Normal file
View File

@ -0,0 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
category: MyString
two:
category: MyString

View File

@ -0,0 +1,7 @@
require 'test_helper'
class WorksCategoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end