mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
add magic link to items
This commit is contained in:
parent
a4ec437b06
commit
b0035ffdbe
@ -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
|
||||
|
||||
5
app/models/content_groupers/item_magic.rb
Normal file
5
app/models/content_groupers/item_magic.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class ItemMagic < ActiveRecord::Base
|
||||
belongs_to :item
|
||||
belongs_to :magic
|
||||
belongs_to :user
|
||||
end
|
||||
@ -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'
|
||||
|
||||
@ -37,6 +37,8 @@
|
||||
:icon: flash_on
|
||||
:attributes:
|
||||
- :name: magic
|
||||
:label: Magical effects
|
||||
- :name: magics
|
||||
:label: Magic
|
||||
:gallery:
|
||||
:label: Gallery
|
||||
|
||||
11
db/migrate/20180131061902_create_item_magics.rb
Normal file
11
db/migrate/20180131061902_create_item_magics.rb
Normal 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
|
||||
14
db/schema.rb
14
db/schema.rb
@ -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
11
test/fixtures/item_magics.yml
vendored
Normal 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:
|
||||
7
test/models/item_magic_test.rb
Normal file
7
test/models/item_magic_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemMagicTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user