parent
e8e6b38b3e
commit
38e5234b64
@ -1,2 +1,14 @@
|
|||||||
class FavoritesController < ApplicationController
|
class FavoritesController < ApplicationController
|
||||||
|
before_action :require_signin
|
||||||
|
def create
|
||||||
|
@movie = Movie.find(params[:movie_id])
|
||||||
|
@movie.favorites.create!(user: current_user)
|
||||||
|
redirect_to @movie
|
||||||
|
end
|
||||||
|
def destroy
|
||||||
|
favorite = current_user.favorites.find(params[:id])
|
||||||
|
favorite.destroy
|
||||||
|
|
||||||
|
redirect_to Movie.find(params[:movie_id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,9 @@
|
|||||||
module FavoritesHelper
|
module FavoritesHelper
|
||||||
|
def fave_or_unfave_button(movie, favorite)
|
||||||
|
if favorite
|
||||||
|
button_to "♡ Unfave", movie_favorite_path(movie, favorite), method: :delete
|
||||||
|
else
|
||||||
|
button_to "♥️ Fave", movie_favorites_path(movie)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in new issue