Class: Accountability::OrderGroupsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Accountability::OrderGroupsController
- Defined in:
- app/controllers/accountability/order_groups_controller.rb
Instance Method Summary collapse
- #add_item ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#add_item ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 46 def add_item product = Product.find(params[:product_id]) if @order_group.add_item! product redirect_to accountability_order_group_path(current_order_group), notice: 'Successfully added to cart' else redirect_back fallback_location: accountability_order_groups_path, alert: 'Failed to add to cart' end end |
#create ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 20 def create @order_group = OrderGroup.new(order_group_params) if @order_group.save redirect_to accountability_order_groups_path, notice: 'Successfully created new order_group' else render :new end end |
#destroy ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 38 def destroy if @order_group.destroy redirect_to accountability_order_groups_path, notice: 'Successfully destroyed order_group' else redirect_to accountability_order_groups_path, alert: 'There was an issue destroying order_group' end end |
#edit ⇒ Object
18 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 18 def edit; end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 8 def index @order_groups = OrderGroup.all end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 12 def new redirect_to accountability_order_group_path(current_order_group) end |
#show ⇒ Object
16 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 16 def show; end |
#update ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 30 def update if @order_group.update(order_group_params) redirect_to accountability_order_groups_path, notice: 'Successfully updated order_group' else render :edit end end |