Sha256: 521e5c2aed1190de14f57f1905dd12d967354d2a09ae10c6c63f621f50196883
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 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") 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree-0.4.0 | app/controllers/admin/products_controller.rb |
spree-0.4.1 | app/controllers/admin/products_controller.rb |