spree/spree — Issue #927: variants_controller.rb - App crashes with no Option types > Option Values
Author: buddhi-desilva
Created: 2011-12-30 19:29:49+00:00
State: open

App crashes when attempting to create a product varient when there are no Option values specified in Option types.

NoMethodError in Spree::Admin::VariantsController#create

undefined method `each_value' for nil:NilClass
Rails.root: /Users/buddhi/Sites/spree_100

Seemingly it's related to this: spree/core/app/controllers/spree/admin/variants_controller.rb: 47

```ruby
def create_before
option_values = params[:new_variant]
option_values.each_value {|id| @object.option_values << OptionValue.find(id)}
@object.save
end
```
Should we simply restrict restrict the creation of variants? or we got to allow the creation of variants with Option Values?