Class: Accountability::ProductsController
- Inherits:
-
AccountabilityController
- Object
- ApplicationController
- AccountabilityController
- Accountability::ProductsController
- Defined in:
- app/controllers/accountability/products_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/accountability/products_controller.rb', line 19 def create @product = Product.new(product_params) if params[:stage] == 'initial' @stage = 'final' render :new elsif @product.save redirect_to accountability_products_path, notice: 'Successfully created new product' else render :new end end |
#destroy ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/controllers/accountability/products_controller.rb', line 40 def destroy if @product.destroy redirect_to accountability_products_path, notice: 'Successfully destroyed product' else redirect_to accountability_products_path, alert: 'There was an issue destroying product' end end |
#edit ⇒ Object
17 |
# File 'app/controllers/accountability/products_controller.rb', line 17 def edit; end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/accountability/products_controller.rb', line 6 def index @products = Product.all end |
#new ⇒ Object
10 11 12 13 |
# File 'app/controllers/accountability/products_controller.rb', line 10 def new @product = Product.new @stage = 'initial' end |
#show ⇒ Object
15 |
# File 'app/controllers/accountability/products_controller.rb', line 15 def show; end |
#update ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/controllers/accountability/products_controller.rb', line 32 def update if @product.update(product_params) redirect_to accountability_products_path, notice: 'Successfully updated product' else render :edit end end |