This commit is contained in:
z9hang 2014-05-09 08:37:49 +08:00
commit bdea0ee36a
7 changed files with 39 additions and 1 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"

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