Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def content_param_list
# Relations
original_ownerships_attributes: [:id, :original_owner_id, :_destroy],
current_ownerships_attributes: [:id, :current_owner_id, :_destroy],
past_ownerships_attributes: [:id, :past_owner_id, :_destroy],
maker_relationships_attributes: [:id, :maker_id, :_destroy],
]
end
Expand Down
8 changes: 8 additions & 0 deletions app/models/content_groupers/past_ownership.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Defines a relation from an Item to a Character that previously owned it
# and an inverse relationship from an Item to all Characters it has been owned by
class PastOwnership < ActiveRecord::Base
belongs_to :user

belongs_to :item
belongs_to :past_owner, class_name: 'Character'
end
3 changes: 2 additions & 1 deletion app/models/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Item < ActiveRecord::Base

# Characters
relates :original_owners, with: :original_ownerships
relates :past_owners, with: :past_ownerships
relates :current_owners, with: :current_ownerships
relates :makers, with: :maker_relationships

Expand All @@ -43,7 +44,7 @@ def self.attribute_categories
},
history: {
icon: 'book',
attributes: %w(original_owners current_owners makers year_made)
attributes: %w(original_owners past_owners current_owners makers year_made)
},
abilities: {
icon: 'flash_on',
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20161001232324_create_past_ownership.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreatePastOwnership < ActiveRecord::Migration
def change
create_table :past_ownerships do |t|
t.integer :user_id
t.integer :item_id
t.integer :past_owner_id
end
end
end
8 changes: 7 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160922204317) do
ActiveRecord::Schema.define(version: 20161001232324) do

create_table "archenemyships", force: :cascade do |t|
t.integer "user_id"
Expand Down Expand Up @@ -206,6 +206,12 @@
t.datetime "updated_at", null: false
end

create_table "past_ownerships", force: :cascade do |t|
t.integer "user_id"
t.integer "item_id"
t.integer "past_owner_id"
end

create_table "sessions", force: :cascade do |t|
t.string "username", null: false
t.string "password", null: false
Expand Down