posts/show: fix flash message when faving/unfaving posts.
Bug: if you faved a post, then opened another page in a separate tab,
then the "You have favorited this post" flash message would appear in
the separate tab.
Fixes regression in bcaee199.
This commit is contained in:
@@ -26,7 +26,7 @@ class FavoritesController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@post = Post.find(params[:post_id])
|
@post = Post.find(params[:post_id])
|
||||||
@post.add_favorite!(CurrentUser.user)
|
@post.add_favorite!(CurrentUser.user)
|
||||||
flash[:notice] = "You have favorited this post"
|
flash.now[:notice] = "You have favorited this post"
|
||||||
|
|
||||||
respond_with(@post)
|
respond_with(@post)
|
||||||
end
|
end
|
||||||
@@ -40,7 +40,7 @@ class FavoritesController < ApplicationController
|
|||||||
Favorite.remove(post_id: params[:id], user: CurrentUser.user)
|
Favorite.remove(post_id: params[:id], user: CurrentUser.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
flash[:notice] = "You have unfavorited this post"
|
flash.now[:notice] = "You have unfavorited this post"
|
||||||
respond_with(@post)
|
respond_with(@post)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user