Skip to content

Commit

Permalink
parent endpoint (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-du authored Feb 7, 2020
1 parent c6afee0 commit f98f22a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/flowchart_node_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def show
render json: node
end

def parent
node = FlowchartNode.find(params[:id])
parent_node = FlowchartNode.find(node.flowchart_node_id)
render json: parent_node
end

def children
node = FlowchartNode.find(params[:id])
node_children = node.children
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
delete '/flowchart/:id', to: 'flowchart#delete'

get '/flowchart_node/:id', to: 'flowchart_node#show'
get '/flowchart_node/:id/parent', to: 'flowchart_node#parent'
get '/flowchart_node/:id/children', to: 'flowchart_node#children'
post '/flowchart_node', to: 'flowchart_node#create'
put '/flowchart_node/swap', to: 'flowchart_node#swap'
Expand Down

0 comments on commit f98f22a

Please sign in to comment.