1.添加资源类型control、model及表结构

2.资源(attachments)添加资源分类属性
This commit is contained in:
nwb 2014-05-08 18:03:48 +08:00
parent b94bd99311
commit 42e6fc6a68
7 changed files with 39 additions and 12 deletions

View File

@ -23,6 +23,7 @@ class Attachment < ActiveRecord::Base
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'"
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
belongs_to :attachmentstype, :foreign_key => "attachtype"
validates_presence_of :filename, :author
validates_length_of :filename, :maximum => 255

View File

@ -0,0 +1,3 @@
class Attachmentstype < ActiveRecord::Base
attr_accessible :typeId, :typeName
end

View File

@ -0,0 +1,12 @@
class CreateAttachmentstypes < ActiveRecord::Migration
def self.up
create_table :attachmentstypes do |t|
t.column :typeId, :integer, :null => false
t.column :typeName, :string, :limit =>50
end
end
def self.down
drop_table :attachmentstypes
end
end

View File

@ -0,0 +1,5 @@
class AddAttachtypeToAttachments < ActiveRecord::Migration
def change
add_column :attachments, :attachtype, :int
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140428013546) do
ActiveRecord::Schema.define(:version => 20140508030358) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -36,6 +36,7 @@ ActiveRecord::Schema.define(:version => 20140428013546) do
t.datetime "created_on"
t.string "description"
t.string "disk_directory"
t.integer "attachtype"
end
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
@ -755,11 +756,6 @@ ActiveRecord::Schema.define(:version => 20140428013546) do
add_index "time_entries", ["project_id"], :name => "time_entries_project_id"
add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id"
create_table "tmp", :force => true do |t|
t.string "name"
t.string "part_number"
end
create_table "tokens", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.string "action", :limit => 30, :default => "", :null => false
@ -966,10 +962,4 @@ ActiveRecord::Schema.define(:version => 20140428013546) do
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"
create_table "yans", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end

9
test/fixtures/attachmentstypes.yml vendored Normal file
View File

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

View File

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