Class: MechanizeStore::ProductCategoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MechanizeStore::ProductCategoriesController
- Defined in:
- app/controllers/mechanize_store/product_categories_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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/mechanize_store/product_categories_controller.rb', line 28 def create @product_category = ProductCategory.new(product_category_params) respond_with @product_category do |format| if @product_category.save format.html do flash[:notice] = I18n.t(:created, model: I18n.t(:product_category, scope: "activerecord.models")) redirect_to @product_category end else format.html { render action: "new" } end end end |
#destroy ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/controllers/mechanize_store/product_categories_controller.rb', line 58 def destroy @product_category = ProductCategory.find(params[:id]) flash[:alert] = I18n.t(:removed, model: I18n.t(:product_category, scope: "activerecord.models")) if @product_category.destroy respond_with @product_category, :location => product_categories_url end |
#edit ⇒ Object
24 25 26 |
# File 'app/controllers/mechanize_store/product_categories_controller.rb', line 24 def edit respond_with @product_category end |
#index ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/controllers/mechanize_store/product_categories_controller.rb', line 7 def index @search = ProductCategory.search(params[:q]) @product_categories = @search.result.paginate(page: params[:page]) respond_with @product_categories end |
#new ⇒ Object
19 20 21 22 |
# File 'app/controllers/mechanize_store/product_categories_controller.rb', line 19 def new @product_category = ProductCategory.new respond_with @product_category end |
#show ⇒ Object
15 16 17 |
# File 'app/controllers/mechanize_store/product_categories_controller.rb', line 15 def show respond_with @product_category end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/mechanize_store/product_categories_controller.rb', line 43 def update @product_category = ProductCategory.find(params[:id]) respond_with @product_category do |format| if @product_category.update(product_category_params) format.html do flash[:notice] = I18n.t(:updated, model: I18n.t(:product_category, scope: "activerecord.models")) redirect_to @product_category end else format.html { render action: "edit" } end end end |