diff --git a/app/models/organization.rb b/app/models/organization.rb new file mode 100644 index 000000000..5f52dee98 --- /dev/null +++ b/app/models/organization.rb @@ -0,0 +1,5 @@ +class Organization < ActiveRecord::Base + attr_accessible :logo_link, :name + + has_many :projects +end diff --git a/app/models/project.rb b/app/models/project.rb index df403bb5c..3ac29249f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/db/migrate/20150305011023_create_organizations.rb b/db/migrate/20150305011023_create_organizations.rb new file mode 100644 index 000000000..798c526c5 --- /dev/null +++ b/db/migrate/20150305011023_create_organizations.rb @@ -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 diff --git a/db/migrate/20150305011359_add_organization_to_project.rb b/db/migrate/20150305011359_add_organization_to_project.rb new file mode 100644 index 000000000..4bf8c4c88 --- /dev/null +++ b/db/migrate/20150305011359_add_organization_to_project.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index d7a1b18bc..d0bee8db6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb new file mode 100644 index 000000000..6f6f99fb4 --- /dev/null +++ b/spec/models/organization_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Organization do + pending "add some examples to (or delete) #{__FILE__}" +end