Sha256: 684426df84a627e39aa1e558fd14bcaa49324fa1399feaf707c025c264cb9d73

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

class Admin::VariantsController < Admin::BaseController
  resource_controller
  belongs_to :product
  before_filter :load_data, :only => [:index, :edit, :new]
  
  new_action.response do |wants|
    wants.html {render :action => :new, :layout => false}
  end

  create.before do 
    option_values = params[:new_variant]
    option_values.each_value {|id| @object.option_values << OptionValue.find(id)}
    @object.save
  end
  
  # redirect to index (instead of r_c default of show view)
  create.response do |wants| 
    wants.html {redirect_to collection_url}
  end

  # redirect to index (instead of r_c default of show view)
  update.response do |wants| 
    wants.html {redirect_to collection_url}
  end
  
  private
  def load_data
    # this allows extensions to provide their own additional columns in the index and edit views
    @additional_fields = Variant.column_names - ["id", "price", "sku", "product_id"]
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree-0.5.0 app/controllers/admin/variants_controller.rb
spree-0.5.1 app/controllers/admin/variants_controller.rb