|
@@ -3,11 +3,11 @@ class Api::V1::ActivitiesController < ApplicationController
|
3
|
3
|
before_action :check_login
|
4
|
4
|
|
5
|
5
|
def index
|
6
|
|
- render json: Activity.all
|
|
6
|
+ render json: ActivitySerializer.new(Activity.all).serializable_hash.to_json
|
7
|
7
|
end
|
8
|
8
|
|
9
|
9
|
def show
|
10
|
|
- render json: Activity.find(params[:id])
|
|
10
|
+ render json: ActivitySerializer.new(@activity).serializable_hash.to_json
|
11
|
11
|
end
|
12
|
12
|
|
13
|
13
|
def create
|
|
@@ -17,7 +17,7 @@ class Api::V1::ActivitiesController < ApplicationController
|
17
|
17
|
user_id: current_user.id,
|
18
|
18
|
activity_id: activity.id
|
19
|
19
|
)
|
20
|
|
- render json: activity, status: :created
|
|
20
|
+ render json: ActivitySerializer.new(activity).serializable_hash.to_json, status: :created
|
21
|
21
|
else
|
22
|
22
|
render json: { errors: activity.errors }, status: :unprocessable_entity
|
23
|
23
|
end
|
|
@@ -25,7 +25,7 @@ class Api::V1::ActivitiesController < ApplicationController
|
25
|
25
|
|
26
|
26
|
def update
|
27
|
27
|
if @activity.update(activity_params)
|
28
|
|
- render json: @activity
|
|
28
|
+ render json: ActivitySerializer.new(@activity).serializable_hash.to_json
|
29
|
29
|
else
|
30
|
30
|
render json: @activity.errors, status: :unprocessable_entity
|
31
|
31
|
end
|