diff --git a/app/helpers/admin/enterprises_helper.rb b/app/helpers/admin/enterprises_helper.rb index dc56e675ee..59945d274c 100644 --- a/app/helpers/admin/enterprises_helper.rb +++ b/app/helpers/admin/enterprises_helper.rb @@ -10,8 +10,8 @@ module Admin end end - def select_only_item(size) - size == 1 ? 1 : nil + def select_only_item(producers) + producers.size == 1 ? producers.first.id : nil end end end diff --git a/app/views/spree/admin/products/new.html.haml b/app/views/spree/admin/products/new.html.haml index 523da01059..80ab5abfbf 100644 --- a/app/views/spree/admin/products/new.html.haml +++ b/app/views/spree/admin/products/new.html.haml @@ -11,7 +11,7 @@ = f.field_container :supplier do = f.label :supplier_id, t(".supplier") %span.required * - = f.collection_select(:supplier_id, @producers, :id, :name, {:include_blank => true, :selected => select_only_item(@producers.size)}, {:class => "select2 fullwidth"}) + = f.collection_select(:supplier_id, @producers, :id, :name, {:include_blank => true, :selected => select_only_item(@producers)}, {:class => "select2 fullwidth"}) = f.error_message_on :supplier .eight.columns.omega = f.field_container :name do