Class: Caboose::ProductImagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::ProductImagesController
- Defined in:
- app/controllers/caboose/product_images_controller.rb
Instance Method Summary collapse
-
#admin_delete ⇒ Object
DELETE /admin/product-images/:id.
-
#admin_update_sort_order ⇒ Object
PUT /admin/products/:product_id/images/sort-order.
-
#admin_variant_ids ⇒ Object
GET /admin/product-images/:id/variant-ids.
-
#admin_variants ⇒ Object
GET /admin/product-images/:id/variants.
-
#variant_images ⇒ Object
GET /variant-images/:id.
Methods inherited from ApplicationController
#admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_edit, #admin_index, #admin_json, #admin_json_single, #admin_update, #before_action, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_delete ⇒ Object
DELETE /admin/product-images/:id
24 25 26 27 28 |
# File 'app/controllers/caboose/product_images_controller.rb', line 24 def admin_delete return if !user_is_allowed('variants', 'delete') img = ProductImage.find(params[:id]).destroy render :json => true end |
#admin_update_sort_order ⇒ Object
PUT /admin/products/:product_id/images/sort-order
38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/caboose/product_images_controller.rb', line 38 def admin_update_sort_order return if !user_is_allowed('products', 'edit') ids = params[:product_image_ids] ids.each_with_index do |id, i| ProductImage.find(id).update_attribute(:position, i) end render :json => { :success => true } end |
#admin_variant_ids ⇒ Object
GET /admin/product-images/:id/variant-ids
9 10 11 12 13 14 |
# File 'app/controllers/caboose/product_images_controller.rb', line 9 def admin_variant_ids return if !user_is_allowed('variants', 'edit') img = ProductImage.find(params[:id]) ids = img.variants.collect{ |v| v.id } render :json => ids end |
#admin_variants ⇒ Object
GET /admin/product-images/:id/variants
17 18 19 20 21 |
# File 'app/controllers/caboose/product_images_controller.rb', line 17 def admin_variants return if !user_is_allowed('variants', 'edit') img = ProductImage.find(params[:id]) render :json => img.variants end |
#variant_images ⇒ Object
GET /variant-images/:id
31 32 33 34 35 |
# File 'app/controllers/caboose/product_images_controller.rb', line 31 def variant_images var = Variant.find(params[:id]) img = var.product_images.first render :json => img end |