Class: Tienda::ProductCategoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Tienda::ProductCategoriesController
- Defined in:
- app/controllers/tienda/product_categories_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/tienda/product_categories_controller.rb', line 16 def create @product_category = Tienda::ProductCategory.new(safe_params) if @product_category.save redirect_to :product_categories, flash: { notice: t('tienda.product_category.create_notice') } else render action: "new" end end |
#destroy ⇒ Object
37 38 39 40 |
# File 'app/controllers/tienda/product_categories_controller.rb', line 37 def destroy @product_category.destroy redirect_to :product_categories, flash: { notice: t('tienda.product_category.destroy_notice') } end |
#edit ⇒ Object
25 26 27 |
# File 'app/controllers/tienda/product_categories_controller.rb', line 25 def edit @parents = Tienda::ProductCategory.all end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/tienda/product_categories_controller.rb', line 7 def index @product_categories = Tienda::ProductCategory.root.ordered.includes(:children) end |
#new ⇒ Object
11 12 13 14 |
# File 'app/controllers/tienda/product_categories_controller.rb', line 11 def new @parents = Tienda::ProductCategory.all @product_category = Tienda::ProductCategory.new end |
#update ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/tienda/product_categories_controller.rb', line 29 def update if @product_category.update(safe_params) redirect_to [:edit, @product_category], flash: { notice: t('tienda.product_category.update_notice') } else render action: "edit" end end |