add magic link to items

This commit is contained in:
Andrew Brown 2018-01-31 00:21:36 -06:00
parent a4ec437b06
commit b0035ffdbe
12 changed files with 51 additions and 1 deletions

View File

@ -21,6 +21,7 @@ class ItemsController < ContentController
current_ownerships_attributes: [:id, :current_owner_id, :_destroy],
past_ownerships_attributes: [:id, :past_owner_id, :_destroy],
maker_relationships_attributes: [:id, :maker_id, :_destroy],
item_magics_attributes: [:id, :magic_id, :_destroy],
]
end
end

View File

@ -0,0 +1,5 @@
class ItemMagic < ActiveRecord::Base
belongs_to :item
belongs_to :magic
belongs_to :user
end

View File

@ -30,6 +30,7 @@ class Item < ActiveRecord::Base
relates :past_owners, with: :past_ownerships
relates :current_owners, with: :current_ownerships
relates :makers, with: :maker_relationships
relates :magics, with: :item_magics
def self.color
'amber'

View File

@ -37,6 +37,8 @@
:icon: flash_on
:attributes:
- :name: magic
:label: Magical effects
- :name: magics
:label: Magic
:gallery:
:label: Gallery

View File

@ -0,0 +1,11 @@
class CreateItemMagics < ActiveRecord::Migration
def change
create_table :item_magics do |t|
t.references :item, index: true, foreign_key: true
t.references :magic, index: true, foreign_key: true
t.references :user, index: true, foreign_key: true
t.timestamps null: false
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180131061726) do
ActiveRecord::Schema.define(version: 20180131061902) do
create_table "archenemyships", force: :cascade do |t|
t.integer "user_id"
@ -933,6 +933,18 @@ ActiveRecord::Schema.define(version: 20180131061726) do
add_index "image_uploads", ["content_type", "content_id"], name: "index_image_uploads_on_content_type_and_content_id"
add_index "image_uploads", ["user_id"], name: "index_image_uploads_on_user_id"
create_table "item_magics", force: :cascade do |t|
t.integer "item_id"
t.integer "magic_id"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "item_magics", ["item_id"], name: "index_item_magics_on_item_id"
add_index "item_magics", ["magic_id"], name: "index_item_magics_on_magic_id"
add_index "item_magics", ["user_id"], name: "index_item_magics_on_user_id"
create_table "items", force: :cascade do |t|
t.string "name", null: false
t.string "item_type"

11
test/fixtures/item_magics.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
item_id:
magic_id:
user_id:
two:
item_id:
magic_id:
user_id:

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ItemMagicTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end