Class: Admin::Shop::CategoriesController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Admin::Shop::CategoriesController
- Defined in:
- app/controllers/admin/shop/categories_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/shop/products/categories POST /admin/shop/products/categories.js POST /admin/shop/products/categories.json AJAX and HTML —————————————————————————-.
-
#destroy ⇒ Object
DELETE /admin/shop/products/categories/1 DELETE /admin/shop/products/categories/1.js DELETE /admin/shop/products/categories/1.json AJAX and HTML —————————————————————————-.
-
#index ⇒ Object
GET /admin/shop/products/categories GET /admin/shop/products/categories.js GET /admin/shop/products/categories.json AJAX and HTML —————————————————————————-.
-
#sort ⇒ Object
PUT /admin/shop/categories/sort PUT /admin/shop/categories/sort.js PUT /admin/shop/categories/sort.json AJAX and HTML —————————————————————————-.
-
#update ⇒ Object
PUT /admin/shop/products/categories/1 PUT /admin/shop/products/categories/1.js PUT /admin/shop/products/categories/1.json AJAX and HTML —————————————————————————-.
Instance Method Details
#create ⇒ Object
POST /admin/shop/products/categories POST /admin/shop/products/categories.js POST /admin/shop/products/categories.json AJAX and HTML
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/admin/shop/categories_controller.rb', line 58 def create notice = 'Category created successfully.' error = 'Could not create Category.' @shop_category.attributes = params[:shop_category] begin @shop_category.save! respond_to do |format| format.html { redirect_to [:edit_admin, @shop_category] if params[:continue] redirect_to admin_shop_categories_path unless params[:continue] } format.js { render :partial => '/admin/shop/categories/index/category', :locals => { :product => @shop_category } } format.json { render :json => @shop_category.to_json } end rescue Exception => error respond_to do |format| format.html { flash[:error] = error render :new } format.js { render :text => error, :status => :unprocessable_entity } format.json { render :json => { :error => error }, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /admin/shop/products/categories/1 DELETE /admin/shop/products/categories/1.js DELETE /admin/shop/products/categories/1.json AJAX and HTML
122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'app/controllers/admin/shop/categories_controller.rb', line 122 def destroy notice = 'Category deleted successfully.' @shop_category.destroy respond_to do |format| format.html { redirect_to admin_shop_categories_path } format.js { render :text => notice, :status => :ok } format.json { render :json => { :notice => notice }, :status => :ok } end end |
#index ⇒ Object
GET /admin/shop/products/categories GET /admin/shop/products/categories.js GET /admin/shop/products/categories.json AJAX and HTML
16 17 18 19 20 21 22 |
# File 'app/controllers/admin/shop/categories_controller.rb', line 16 def index respond_to do |format| format.html { redirect_to admin_shop_products_path } format.js { render :partial => '/admin/shop/categories/index/category', :collection => @shop_categories } format.json { render :json => @shop_categories.to_json } end end |
#sort ⇒ Object
PUT /admin/shop/categories/sort PUT /admin/shop/categories/sort.js PUT /admin/shop/categories/sort.json AJAX and HTML
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/admin/shop/categories_controller.rb', line 28 def sort notice = 'Categories successfully sorted.' error = 'Could not sort Categories.' begin ShopCategory.sort(CGI::parse(params[:categories])["categories[]"]) respond_to do |format| format.html { redirect_to admin_shop_products_path } format.js { render :text => notice, :status => :ok } format.json { render :json => { :notice => notice }, :status => :ok } end rescue respond_to do |format| format.html { flash[:error] = error redirect_to admin_shop_products_path } format.js { render :text => error, :status => :unprocessable_entity } format.json { render :json => { :error => error }, :status => :unprocessable_entity } end end end |
#update ⇒ Object
PUT /admin/shop/products/categories/1 PUT /admin/shop/products/categories/1.js PUT /admin/shop/products/categories/1.json AJAX and HTML
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/controllers/admin/shop/categories_controller.rb', line 91 def update notice = 'Category updated successfully.' error = 'Could not update Category.' begin @shop_category.update_attributes!(params[:shop_category]) respond_to do |format| format.html { redirect_to edit_admin_shop_category_path(@shop_category) if params[:continue] redirect_to admin_shop_categories_path unless params[:continue] } format.js { render :partial => '/admin/shop/categories/index/category', :locals => { :product => @shop_category } } format.json { render :json => @shop_category.to_json } end rescue Exception => error respond_to do |format| format.html { flash[:error] = error render :edit } format.js { render :text => error, :status => :unprocessable_entity } format.json { render :json => { :error => error }, :status => :unprocessable_entity } end end end |