Skip to content
Browse files

Build option value if one doesn't already exist in OptionTypesController

this is so the link to add a new one renders a new row correctly
  • Loading branch information...
1 parent 3e32ad1 commit 76af323617d347d35dfc34e2658ac54c598fb882 @radar radar committed Jun 13, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 core/app/controllers/spree/admin/option_types_controller.rb
View
5 core/app/controllers/spree/admin/option_types_controller.rb
@@ -2,6 +2,7 @@ module Spree
module Admin
class OptionTypesController < ResourceController
before_filter :load_product, :only => [:select, :selected, :available, :remove]
+ before_filter :setup_new_option_value, :only => [:edit]
def available
set_available_option_types
@@ -59,6 +60,10 @@ def location_after_save
def load_product
@product = Product.find_by_param!(params[:product_id])
end
+
+ def setup_new_option_value
+ @option_type.option_values.build if @option_type.option_values.empty?
+ end
def set_available_option_types
@available_option_types = if @product.option_type_ids.any?

0 comments on commit 76af323

Please sign in to comment.
Something went wrong with that request. Please try again.