Browse Source

index def now return every tasks if requested

Lou 3 years ago
parent
commit
8669e0945d
2 changed files with 6 additions and 1 deletions
  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 View File

3
   before_action :check_login
3
   before_action :check_login
4
 
4
 
5
   def index
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
   end
11
   end
8
 
12
 
9
   def show
13
   def show

+ 1
- 0
config/routes.rb View File

6
       resources :activities do
6
       resources :activities do
7
         resources :tasks
7
         resources :tasks
8
       end
8
       end
9
+      resources :tasks
9
     end
10
     end
10
   end
11
   end
11
 end
12
 end

Loading…
Cancel
Save