1、增加组织相关数据表

2、增加组织和项目的关联关系
This commit is contained in:
sw 2015-03-05 09:27:13 +08:00
parent ef5b7c9fca
commit bcc8abdee9
6 changed files with 41 additions and 2 deletions

View File

@ -0,0 +1,5 @@
class Organization < ActiveRecord::Base
attr_accessible :logo_link, :name
has_many :projects
end

View File

@ -90,7 +90,9 @@ class Project < ActiveRecord::Base
:association_foreign_key => 'custom_field_id'
has_many :tags, :through => :project_tags, :class_name => 'Tag'
has_many :project_tags, :class_name => 'ProjectTags'
has_many :project_tags, :class_name => 'ProjectTags'
belongs_to :organization
# has_many :journals

View File

@ -0,0 +1,10 @@
class CreateOrganizations < ActiveRecord::Migration
def change
create_table :organizations do |t|
t.string :name
t.string :logo_link
t.timestamps
end
end
end

View File

@ -0,0 +1,9 @@
class AddOrganizationToProject < ActiveRecord::Migration
def up
add_column :projects, :organization_id, :integer
end
def down
remove_column :projects, :organization_id
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 => 20150128032421) do
ActiveRecord::Schema.define(:version => 20150305011359) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -802,6 +802,13 @@ ActiveRecord::Schema.define(:version => 20150128032421) do
t.integer "project_id"
end
create_table "organizations", :force => true do |t|
t.string "name"
t.string "logo_link"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "poll_answers", :force => true do |t|
t.integer "poll_question_id"
t.text "answer_text"
@ -926,6 +933,7 @@ ActiveRecord::Schema.define(:version => 20150128032421) do
t.integer "user_id"
t.integer "dts_test", :default => 0
t.string "enterprise_name"
t.integer "organization_id"
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Organization do
pending "add some examples to (or delete) #{__FILE__}"
end