Fix auto-reload nerfing scope_xx_to_hub

This commit is contained in:
Rohan Mitchell
2015-01-12 14:01:43 +11:00
parent d52b6b34e3
commit 494bb1f3b4
4 changed files with 17 additions and 10 deletions

View File

@@ -1,4 +1,8 @@
require 'open_food_network/scope_product_to_hub'
Spree::Product.class_eval do
include OpenFoodNetwork::ProductScopableToHub
# We have an after_destroy callback on Spree::ProductOptionType. However, if we
# don't specify dependent => destroy on this association, it is not called. See:
# https://github.com/rails/rails/issues/7618

View File

@@ -1,7 +1,10 @@
require 'open_food_network/scope_variant_to_hub'
require 'open_food_network/enterprise_fee_calculator'
require 'open_food_network/option_value_namer'
Spree::Variant.class_eval do
include OpenFoodNetwork::VariantScopableToHub
has_many :exchange_variants, dependent: :destroy
has_many :exchanges, through: :exchange_variants

View File

@@ -6,11 +6,11 @@ module OpenFoodNetwork
super.each { |v| v.scope_to_hub @hub }
end
end
end
Spree::Product.class_eval do
def scope_to_hub(hub)
extend OpenFoodNetwork::ScopeProductToHub
@hub = hub
module ProductScopableToHub
def scope_to_hub(hub)
extend OpenFoodNetwork::ScopeProductToHub
@hub = hub
end
end
end

View File

@@ -20,11 +20,11 @@ module OpenFoodNetwork
end
end
end
end
Spree::Variant.class_eval do
def scope_to_hub(hub)
extend OpenFoodNetwork::ScopeVariantToHub
@hub = hub
module VariantScopableToHub
def scope_to_hub(hub)
extend OpenFoodNetwork::ScopeVariantToHub
@hub = hub
end
end
end