Class: Accountability::OrderGroupsController
- Inherits:
-
AccountabilityController
- Object
- ApplicationController
- AccountabilityController
- 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
44 45 46 47 48 49 50 51 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 44 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
18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 18 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
36 37 38 39 40 41 42 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 36 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
16 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 16 def edit; end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 6 def index @order_groups = OrderGroup.all end |
#new ⇒ Object
10 11 12 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 10 def new redirect_to accountability_order_group_path(current_order_group) end |
#show ⇒ Object
14 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 14 def show; end |
#update ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/accountability/order_groups_controller.rb', line 28 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 |