Commit 1dca4928fdce5d612ea86d1e87885d3f8428c079
1 parent
92376e38
Exists in
master
and in
28 other branches
ActionItem0: removing user model
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@63 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
8 changed files
with
34 additions
and
57 deletions
Show diff stats
app/controllers/application.rb
@@ -10,8 +10,8 @@ class ApplicationController < ActionController::Base | @@ -10,8 +10,8 @@ class ApplicationController < ActionController::Base | ||
10 | #We have to see a better way to do that | 10 | #We have to see a better way to do that |
11 | before_filter :load_boxes | 11 | before_filter :load_boxes |
12 | def load_boxes | 12 | def load_boxes |
13 | - if User.exists?(1) | ||
14 | - owner = User.find(1) | 13 | + if Profile.exists?(1) |
14 | + owner = Profile.find(1) | ||
15 | owner.nil? ? Array.new : @boxes = owner.boxes | 15 | owner.nil? ? Array.new : @boxes = owner.boxes |
16 | end | 16 | end |
17 | end | 17 | end |
app/models/profile.rb
@@ -13,6 +13,7 @@ class Profile < ActiveRecord::Base | @@ -13,6 +13,7 @@ class Profile < ActiveRecord::Base | ||
13 | ] | 13 | ] |
14 | 14 | ||
15 | has_many :domains, :as => :owner | 15 | has_many :domains, :as => :owner |
16 | + has_many :boxes, :as => :owner | ||
16 | belongs_to :virtual_community | 17 | belongs_to :virtual_community |
17 | 18 | ||
18 | validates_presence_of :identifier | 19 | validates_presence_of :identifier |
app/models/user.rb
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | +class ActsAsTaggableMigration < ActiveRecord::Migration | ||
2 | + def self.up | ||
3 | + create_table :tags do |t| | ||
4 | + t.column :name, :string | ||
5 | + t.column :parent_id, :integer | ||
6 | + t.column :pending, :bool | ||
7 | + end | ||
8 | + | ||
9 | + create_table :taggings do |t| | ||
10 | + t.column :tag_id, :integer | ||
11 | + t.column :taggable_id, :integer | ||
12 | + | ||
13 | + # You should make sure that the column created is | ||
14 | + # long enough to store the required class names. | ||
15 | + t.column :taggable_type, :string | ||
16 | + | ||
17 | + t.column :created_at, :datetime | ||
18 | + end | ||
19 | + | ||
20 | + add_index :taggings, :tag_id | ||
21 | + add_index :taggings, [:taggable_id, :taggable_type] | ||
22 | + end | ||
23 | + | ||
24 | + def self.down | ||
25 | + drop_table :taggings | ||
26 | + drop_table :tags | ||
27 | + end | ||
28 | +end |
db/migrate/006_create_users.rb
db/migrate/007_acts_as_taggable_migration.rb
@@ -1,28 +0,0 @@ | @@ -1,28 +0,0 @@ | ||
1 | -class ActsAsTaggableMigration < ActiveRecord::Migration | ||
2 | - def self.up | ||
3 | - create_table :tags do |t| | ||
4 | - t.column :name, :string | ||
5 | - t.column :parent_id, :integer | ||
6 | - t.column :pending, :bool | ||
7 | - end | ||
8 | - | ||
9 | - create_table :taggings do |t| | ||
10 | - t.column :tag_id, :integer | ||
11 | - t.column :taggable_id, :integer | ||
12 | - | ||
13 | - # You should make sure that the column created is | ||
14 | - # long enough to store the required class names. | ||
15 | - t.column :taggable_type, :string | ||
16 | - | ||
17 | - t.column :created_at, :datetime | ||
18 | - end | ||
19 | - | ||
20 | - add_index :taggings, :tag_id | ||
21 | - add_index :taggings, [:taggable_id, :taggable_type] | ||
22 | - end | ||
23 | - | ||
24 | - def self.down | ||
25 | - drop_table :taggings | ||
26 | - drop_table :tags | ||
27 | - end | ||
28 | -end |
test/fixtures/boxes.yml
@@ -2,15 +2,15 @@ | @@ -2,15 +2,15 @@ | ||
2 | one: | 2 | one: |
3 | id: 1 | 3 | id: 1 |
4 | number: 1 | 4 | number: 1 |
5 | - owner_type: 'User' | 5 | + owner_type: 'Profile' |
6 | owner_id: 1 | 6 | owner_id: 1 |
7 | two: | 7 | two: |
8 | id: 2 | 8 | id: 2 |
9 | number: 2 | 9 | number: 2 |
10 | - owner_type: 'User' | 10 | + owner_type: 'Profile' |
11 | owner_id: 1 | 11 | owner_id: 1 |
12 | three: | 12 | three: |
13 | id: 3 | 13 | id: 3 |
14 | number: 3 | 14 | number: 3 |
15 | - owner_type: 'User' | 15 | + owner_type: 'Profile' |
16 | owner_id: 1 | 16 | owner_id: 1 |