Skip to content
Snippets Groups Projects
Commit 2013314f authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch '256-follow-PUT' into 'master'

Added PUT route & follow_toggle action (closes SCRUM#256)

Closes SCRUM#256

See merge request !430
parents 54eb410d 38c1dcb8
No related branches found
No related tags found
No related merge requests found
...@@ -28,4 +28,18 @@ module FollowableController ...@@ -28,4 +28,18 @@ module FollowableController
render status: :forbidden render status: :forbidden
end end
end end
# PUT /v1/users/1/follow
# PUT /v1/users/1/follow.json
def follow_toggle
if !current_user.following?(followable)
current_user.follow(followable)
render status: :created
elsif current_user.following?(followable)
current_user.unfollow(followable)
render status: :ok
else
render status: :forbidden
end
end
end end
...@@ -13,6 +13,7 @@ Rails.application.routes.draw do ...@@ -13,6 +13,7 @@ Rails.application.routes.draw do
member do member do
post 'follow', as: :follow, action: :follow post 'follow', as: :follow, action: :follow
delete 'follow', as: :unfollow, action: :unfollow delete 'follow', as: :unfollow, action: :unfollow
put 'follow', as: :follow_toggle, action: :follow_toggle
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment