Class: Gemgento::User::WishlistItemsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Gemgento::User::WishlistItemsController
- Defined in:
- app/controllers/gemgento/user/wishlist_items_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/gemgento/user/wishlist_items_controller.rb', line 12 def create @wishlist_item = current_user.wishlist_items.new(wishlist_item_params) respond_to do |format| if @wishlist_item.save format.html { redirect_to user_wishlist_items_path, notice: "Item sucessfully added to wishlist." } format.json { render json: { result: true, wishlist_item: @wishlist_item } } else format.html { redirect_to user_wishlist_items_path } format.json { render json: { result: false, errors: @wishlist_item.errors. } } end end end |
#destroy ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/gemgento/user/wishlist_items_controller.rb', line 26 def destroy @wishlist_item = current_user.wishlist_items.find(params[:id]) respond_to do |format| if @wishlist_item.destroy format.html { redirect_to user_wishlist_items_path , notice: "Wishlist item removed." } format.json { render json: { result: true } } else format.html { render user_wishlist_items_path, alert: 'Unable to remove item from wishlist' } format.json { render json: { result: false, errors: @wishlist_item.errors. } } end end end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/gemgento/user/wishlist_items_controller.rb', line 7 def index @wishlist_items = current_user.wishlist_items respond_with @wishlist_items end |