Fix saving weapons to parties
This commit is contained in:
parent
e97afb72bc
commit
5d5a09f552
3 changed files with 8 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
attributes :id,
|
||||
:party_id,
|
||||
:mainhand,
|
||||
:position
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
object @grid_weapon
|
||||
object @weapon
|
||||
|
||||
extends 'api/v1/grid_weapons/base'
|
||||
Loading…
Reference in a new issue