Class: Spree::FavoriteProductsController
- Inherits:
-
StoreController
- Object
- StoreController
- Spree::FavoriteProductsController
- Defined in:
- app/controllers/spree/favorite_products_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/spree/favorite_products_controller.rb', line 11 def create favorite = spree_current_user.favorites.new :product_id => params[:id] if @success = favorite.save = "Product has been successfully marked as favorite" else = favorite.errors..to_sentence end respond_to do |format| format.js end end |
#destroy ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/spree/favorite_products_controller.rb', line 23 def destroy if @favorite @success = @favorite.destroy end end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/spree/favorite_products_controller.rb', line 7 def index @favorite_products = spree_current_user.favorite_products.page(params[:page]).per(Spree::Config.favorite_products_per_page) end |