From 1dca4928fdce5d612ea86d1e87885d3f8428c079 Mon Sep 17 00:00:00 2001 From: LeandroNunes Date: Tue, 10 Jul 2007 10:30:24 +0000 Subject: [PATCH] ActionItem0: removing user model --- app/controllers/application.rb | 4 ++-- app/models/profile.rb | 1 + app/models/user.rb | 3 --- db/migrate/006_acts_as_taggable_migration.rb | 28 ++++++++++++++++++++++++++++ db/migrate/006_create_users.rb | 11 ----------- db/migrate/007_acts_as_taggable_migration.rb | 28 ---------------------------- test/fixtures/boxes.yml | 6 +++--- test/unit/user_test.rb | 10 ---------- 8 files changed, 34 insertions(+), 57 deletions(-) delete mode 100644 app/models/user.rb create mode 100644 db/migrate/006_acts_as_taggable_migration.rb delete mode 100644 db/migrate/006_create_users.rb delete mode 100644 db/migrate/007_acts_as_taggable_migration.rb delete mode 100644 test/unit/user_test.rb diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 7f1fd09..2b3dbb8 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -10,8 +10,8 @@ class ApplicationController < ActionController::Base #We have to see a better way to do that before_filter :load_boxes def load_boxes - if User.exists?(1) - owner = User.find(1) + if Profile.exists?(1) + owner = Profile.find(1) owner.nil? ? Array.new : @boxes = owner.boxes end end diff --git a/app/models/profile.rb b/app/models/profile.rb index 5e13a62..4ff768a 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -13,6 +13,7 @@ class Profile < ActiveRecord::Base ] has_many :domains, :as => :owner + has_many :boxes, :as => :owner belongs_to :virtual_community validates_presence_of :identifier diff --git a/app/models/user.rb b/app/models/user.rb deleted file mode 100644 index 8d33177..0000000 --- a/app/models/user.rb +++ /dev/null @@ -1,3 +0,0 @@ -class User < ActiveRecord::Base - has_many :boxes, :as => :owner -end diff --git a/db/migrate/006_acts_as_taggable_migration.rb b/db/migrate/006_acts_as_taggable_migration.rb new file mode 100644 index 0000000..4d8b7ee --- /dev/null +++ b/db/migrate/006_acts_as_taggable_migration.rb @@ -0,0 +1,28 @@ +class ActsAsTaggableMigration < ActiveRecord::Migration + def self.up + create_table :tags do |t| + t.column :name, :string + t.column :parent_id, :integer + t.column :pending, :bool + end + + create_table :taggings do |t| + t.column :tag_id, :integer + t.column :taggable_id, :integer + + # You should make sure that the column created is + # long enough to store the required class names. + t.column :taggable_type, :string + + t.column :created_at, :datetime + end + + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type] + end + + def self.down + drop_table :taggings + drop_table :tags + end +end diff --git a/db/migrate/006_create_users.rb b/db/migrate/006_create_users.rb deleted file mode 100644 index 7a78c7b..0000000 --- a/db/migrate/006_create_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def self.up - create_table :users do |t| - t.column :name, :string - end - end - - def self.down - drop_table :users - end -end diff --git a/db/migrate/007_acts_as_taggable_migration.rb b/db/migrate/007_acts_as_taggable_migration.rb deleted file mode 100644 index 4d8b7ee..0000000 --- a/db/migrate/007_acts_as_taggable_migration.rb +++ /dev/null @@ -1,28 +0,0 @@ -class ActsAsTaggableMigration < ActiveRecord::Migration - def self.up - create_table :tags do |t| - t.column :name, :string - t.column :parent_id, :integer - t.column :pending, :bool - end - - create_table :taggings do |t| - t.column :tag_id, :integer - t.column :taggable_id, :integer - - # You should make sure that the column created is - # long enough to store the required class names. - t.column :taggable_type, :string - - t.column :created_at, :datetime - end - - add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type] - end - - def self.down - drop_table :taggings - drop_table :tags - end -end diff --git a/test/fixtures/boxes.yml b/test/fixtures/boxes.yml index 953874e..4a333a3 100644 --- a/test/fixtures/boxes.yml +++ b/test/fixtures/boxes.yml @@ -2,15 +2,15 @@ one: id: 1 number: 1 - owner_type: 'User' + owner_type: 'Profile' owner_id: 1 two: id: 2 number: 2 - owner_type: 'User' + owner_type: 'Profile' owner_id: 1 three: id: 3 number: 3 - owner_type: 'User' + owner_type: 'Profile' owner_id: 1 diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb deleted file mode 100644 index 5468f7a..0000000 --- a/test/unit/user_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class UserTest < Test::Unit::TestCase - fixtures :users - - # Replace this with your real tests. - def test_truth - assert true - end -end -- libgit2 0.21.2