app/controllers/admin/variants_controller.rb in spree-0.9.4 vs app/controllers/admin/variants_controller.rb in spree-0.10.0.beta
- old
+ new
@@ -4,15 +4,11 @@
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
+ create.before :create_before
# redirect to index (instead of r_c default of show view)
create.response do |wants|
wants.html {redirect_to collection_url}
end
@@ -31,14 +27,23 @@
if @variant.save
flash[:notice] = "Variant has been deleted"
else
flash[:notice] = "Variant could not be deleted"
end
-
- redirect_to admin_product_variants_url(params[:product_id])
+
+ respond_to do |format|
+ format.html { redirect_to admin_product_variants_url(params[:product_id]) }
+ format.js { render_js_for_destroy }
+ end
end
private
+ def create_before
+ option_values = params[:new_variant]
+ option_values.each_value {|id| @object.option_values << OptionValue.find(id)}
+ @object.save
+ end
+
def collection
@deleted = (params.key?(:deleted) && params[:deleted] == "on") ? "checked" : ""
if @deleted.blank?
@collection ||= end_of_association_chain.active.find(:all)