Sha256: 4163e06a7f610d03d64577577c5062e8cf8130c5be323fa12f88b40bf18f0570
Contents?: true
Size: 1.84 KB
Versions: 2
Compression:
Stored size: 1.84 KB
Contents
class Admin::ProductsController < Admin::BaseController resource_controller before_filter :load_data after_filter :set_image, :only => [:create, :update] update.before do # note: we only reset the product properties if we're receiving a post from the form on that tab next unless params[:clear_product_properties] params[:product] ||= {} params[:product][:product_property_attributes] ||= {} if params[:product][:product_property_attributes].nil? end update.response do |wants| # override the default redirect behavior of r_c wants.html {redirect_to edit_object_url} end private def load_data @tax_categories = TaxCategory.find(:all, :order=>"name") @shipping_categories = ShippingCategory.find(:all, :order=>"name") end def set_image return unless params[:image] return if params[:image][:uploaded_data].blank? image = Image.create params[:image] if params[:image] object.images << image end def collection @name = params[:name] || "" @sku = params[:sku] || "" if @sku.blank? @collection ||= end_of_association_chain.by_name(@name).find(:all, :order => :name, :page => {:start => 1, :size => 10, :current => params[:p]}) else @collection ||= end_of_association_chain.by_name(@name).by_sku(@sku).find(:all, :order => :name, :page => {:start => 1, :size => 10, :current => params[:p]}) end end # override rc_default build b/c we need to make sure there's an empty variant added to each product def build_object @object ||= Product.new params[:product] if @object.variants.empty? @object.available_on = Time.now @object.variants << Variant.new(:product => @object) end @object.variant.sku = params[:product] ? params[:product][:sku] : "" @object end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree-0.5.0 | app/controllers/admin/products_controller.rb |
spree-0.5.1 | app/controllers/admin/products_controller.rb |