Skip to content
Browse files

Fix for problem with Product#images for newly created Products

  • Loading branch information...
1 parent 558f8c9 commit 4831f0a756644e603a4b68888ebd98f775f0482d @alexdowad alexdowad committed with radar May 14, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 core/app/models/spree/product.rb
View
1 core/app/models/spree/product.rb
@@ -59,6 +59,7 @@ class Product < ActiveRecord::Base
accepts_nested_attributes_for :variants, :allow_destroy => true
def variant_images
+ return [] if self.id.nil? # newly created record?
Image.find_by_sql("SELECT #{Asset.quoted_table_name}.* FROM #{Asset.quoted_table_name} LEFT JOIN #{Variant.quoted_table_name} ON (#{Variant.quoted_table_name}.id = #{Asset.quoted_table_name}.viewable_id) WHERE (#{Variant.quoted_table_name}.product_id = #{self.id}) ORDER BY #{Asset.quoted_table_name}.position")
end

0 comments on commit 4831f0a

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