Class: FavoritesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- FavoritesController
- Defined in:
- app/controllers/favorites_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
4 5 6 7 |
# File 'app/controllers/favorites_controller.rb', line 4 def create Favorite.create!({user: current_user, favoriteable: model}, without_protection: true) unless current_user.favorites.find_by_favoriteable_id_and_favoriteable_type(model.id, model.class) render nothing: true end |
#destroy ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/favorites_controller.rb', line 8 def destroy favorite = current_user.favorites.find(params[:id]) raise ActiveRecord::RecordNotFound if favorite.favoriteable != model favorite.destroy render nothing: true end |