diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index 72da0e52b1..36473d4e24 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -28,7 +28,6 @@ Spree::Product.class_eval do after_initialize :set_available_on_to_now, :if => :new_record? after_save :update_units before_save :add_primary_taxon_to_taxons - before_validation :set_primary_taxon_to_first_taxon # -- Joins @@ -163,10 +162,6 @@ Spree::Product.class_eval do end end - def set_primary_taxon_to_first_taxon - self.primary_taxon = taxons.first unless primary_taxon - end - def add_primary_taxon_to_taxons taxons << primary_taxon unless taxons.find_by_id(primary_taxon) end diff --git a/app/views/shopping_shared/_about.html.haml b/app/views/shopping_shared/_about.html.haml index 0fbfc1cc11..e03eb05255 100644 --- a/app/views/shopping_shared/_about.html.haml +++ b/app/views/shopping_shared/_about.html.haml @@ -3,5 +3,6 @@ .small-12.large-9.columns %p= current_distributor.long_description.andand.html_safe .small-12.large-3.columns - %img.about.right{src: current_distributor.promo_image.url(:large)} + / Hide image until image styles are working correctly: + / %img.about.right{src: current_distributor.promo_image.url(:large)} diff --git a/db/migrate/20140522044009_add_primary_taxon_to_products.rb b/db/migrate/20140522044009_add_primary_taxon_to_products.rb index fb7b9b3160..28c27f820f 100644 --- a/db/migrate/20140522044009_add_primary_taxon_to_products.rb +++ b/db/migrate/20140522044009_add_primary_taxon_to_products.rb @@ -1,15 +1,18 @@ class AddPrimaryTaxonToProducts < ActiveRecord::Migration - def change + def up add_column :spree_products, :primary_taxon_id, :integer -<<<<<<< HEAD -<<<<<<< HEAD + add_index :spree_products, :primary_taxon_id add_foreign_key :spree_products, :spree_taxons, column: :primary_taxon_id -======= ->>>>>>> fd1e7eb... Adding primary taxon field to product -======= - add_index :spree_products, :primary_taxon_id - add_foreign_key :spree_products, :spree_taxons, column: :primary_taxon_id ->>>>>>> 110a6f2... Adding primary taxon to admin forms + + Spree::Product.all.each do |p| + p.update_column :primary_taxon_id, (p.taxons.first || Spree::Taxon.first) + end + + change_column :spree_products, :primary_taxon_id, :integer, null: false + end + + def down + remove_column :spree_products, :primary_taxon_id end end diff --git a/db/schema.rb b/db/schema.rb index 6005fd7cb5..999ff55705 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -681,7 +681,7 @@ ActiveRecord::Schema.define(:version => 20140522044009) do t.float "variant_unit_scale" t.string "variant_unit_name" t.text "notes" - t.integer "primary_taxon_id" + t.integer "primary_taxon_id", :null => false end add_index "spree_products", ["available_on"], :name => "index_products_on_available_on" diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index b1b905fe82..ecc988f7ea 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -24,7 +24,6 @@ feature "As a consumer I want to shop with a distributor", js: true do page.should have_text distributor.name find("#tab_about a").click first("distributor img")['src'].should == distributor.logo.url(:thumb) - first("#about img")['src'].should == distributor.promo_image.url(:large) end it "shows the producers for a distributor" do