Sha256: 291d518c194200fe2a6eaff9c12ea822ee089583aa29704aaca6c021690a43b4
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 KB
Contents
module Shoppe class ProductsController < Shoppe::ApplicationController before_filter { @active_nav = :products } before_filter { params[:id] && @product = Shoppe::Product.root.find(params[:id]) } def index @products = Shoppe::Product.root.includes(:stock_level_adjustments, :default_image, :product_categories, :variants).order(:name).group_by(&:product_category).sort_by { |cat,pro| cat.name } end def new @product = Shoppe::Product.new end def create @product = Shoppe::Product.new(safe_params) if @product.save redirect_to :products, :flash => {:notice => t('shoppe.products.create_notice') } else render :action => "new" end end def edit end def update if @product.update(safe_params) redirect_to [:edit, @product], :flash => {:notice => t('shoppe.products.update_notice') } else render :action => "edit" end end def destroy @product.destroy redirect_to :products, :flash => {:notice => t('shoppe.products.destroy_notice')} end def import if request.post? if params[:import].nil? redirect_to import_products_path, :flash => {:alert => I18n.t('shoppe.imports.errors.no_file')} else Shoppe::Product.import(params[:import][:import_file]) redirect_to products_path, :flash => {:notice => I18n.t("shoppe.products.imports.success")} end end end private def safe_params params[:product].permit(:name, :sku, :permalink, :description, :short_description, :weight, :price, :cost_price, :tax_rate_id, :stock_control, :default_image_file, :data_sheet_file, :active, :featured, :in_the_box, :product_attributes_array => [:key, :value, :searchable, :public], :product_category_ids => []) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shoppe-1.0.7 | app/controllers/shoppe/products_controller.rb |
shoppe-1.0.6 | app/controllers/shoppe/products_controller.rb |