Class: Api::V3::NodesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/api/v3/nodes_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#admin?, #can?, #current_ability, #current_user, #error!, #error_404!, #optional!, #requires!

Instance Method Details

#indexObject

获取 Nodes 列表

GET /api/v3/nodes


10
11
12
13
# File 'app/controllers/api/v3/nodes_controller.rb', line 10

def index
  @nodes = Node.includes(:section).all
  render json: @nodes, meta: { total: Node.count }
end

#showObject

获取单个 Node 详情

GET /api/v3/nodes/:id


20
21
22
23
# File 'app/controllers/api/v3/nodes_controller.rb', line 20

def show
  @node = Node.find(params[:id])
  render json: @node
end