Temp fix for tools endpoint

pull/300/head
Rick Carlino 2016-12-05 13:21:04 -06:00
parent 3e90e9e792
commit 56449bb1f0
2 changed files with 25 additions and 3 deletions

View File

@ -31,7 +31,15 @@ private
end
def create_params
{name: params[:name], tool_slot: tool_slot }
if @create_params
@create_params
else
tsid = params[:tool_slot_id]
@create_params = { name: params[:name],
device: current_device }
@create_params[:tool_slot_id] = tsid if tsid
@create_params
end
end
def q

View File

@ -2,11 +2,25 @@ module Tools
class Create < Mutations::Command
required do
string :name
model :tool_slot, class: ToolSlot
model :device, class: Device
end
optional do
integer :tool_slot_id
end
def validate
puts "TODO: Validate user authorizations"
end
def execute
Tool.create!(inputs)
Tool.create!(inputs.except(:device))
end
private
def query
@query ||= ToolBay::DeviceQuery.new(device)
end
end
end