favorites: unify create.js.erb & destory.js.erb code paths.

This commit is contained in:
evazion
2018-08-12 15:49:13 -05:00
parent fb91bbc6c5
commit bcaee199f5
4 changed files with 20 additions and 26 deletions

View File

@@ -26,6 +26,7 @@ class FavoritesController < ApplicationController
def create
@post = Post.find(params[:post_id])
@post.add_favorite!(CurrentUser.user)
flash[:notice] = "You have favorited this post"
respond_with(@post)
end
@@ -39,6 +40,7 @@ class FavoritesController < ApplicationController
Favorite.remove(post_id: params[:id], user: CurrentUser.user)
end
flash[:notice] = "You have unfavorited this post"
respond_with(@post)
end
end