Fix saving weapons to parties

This commit is contained in:
Justin Edmund 2020-09-26 10:51:03 -07:00
parent e97afb72bc
commit 5d5a09f552
3 changed files with 8 additions and 3 deletions

View file

@ -2,13 +2,17 @@ class Api::V1::GridWeaponsController < Api::V1::ApiController
def create
party = Party.find(weapon_params[:party_id])
canonical_weapon = Weapon.find(weapon_params[:weapon_id])
if current_user
if party.user != current_user
render_unauthorized_response
end
end
if grid_weapon = GridWeapon.where(
party_id: party.id,
position: weapon_params[:position]
).first
ap "Grid weapon found!"
ap grid_weapon
GridWeapon.destroy(grid_weapon.id)
end

View file

@ -1,4 +1,5 @@
attributes :id,
:party_id,
:mainhand,
:position

View file

@ -1,3 +1,3 @@
object @grid_weapon
object @weapon
extends 'api/v1/grid_weapons/base'