Pārlūkot izejas kodu

index def now return every tasks if requested

Lou 3 gadus atpakaļ
vecāks
revīzija
8669e0945d
2 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 5
    1
      app/controllers/api/v1/tasks_controller.rb
  2. 1
    0
      config/routes.rb

+ 5
- 1
app/controllers/api/v1/tasks_controller.rb Parādīt failu

@@ -3,7 +3,11 @@ class Api::V1::TasksController < ApplicationController
3 3
   before_action :check_login
4 4
 
5 5
   def index
6
-    render json: TaskSerializer.new(Activity.find(params[:activity_id]).tasks).serializable_hash.to_json
6
+    if !params[:activity_id]
7
+      render json: TaskSerializer.new(Task.all).serializable_hash.to_json
8
+    else
9
+      render json: TaskSerializer.new(Activity.find(params[:activity_id]).tasks).serializable_hash.to_json
10
+    end
7 11
   end
8 12
 
9 13
   def show

+ 1
- 0
config/routes.rb Parādīt failu

@@ -6,6 +6,7 @@ Rails.application.routes.draw do
6 6
       resources :activities do
7 7
         resources :tasks
8 8
       end
9
+      resources :tasks
9 10
     end
10 11
   end
11 12
 end

Notiek ielāde…
Atcelt
Saglabāt