Kaynağa Gözat

index def now return every tasks if requested

Lou 3 yıl önce
ebeveyn
işleme
8669e0945d

+ 5
- 1
app/controllers/api/v1/tasks_controller.rb Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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

Loading…
İptal
Kaydet