From c61f4d6cf118d1724da3399617edb708b2f8c00b Mon Sep 17 00:00:00 2001 From: Brendan Deere Date: Mon, 22 May 2017 09:02:31 -0700 Subject: Only load permitted attributes once Previous Behaviour: The to_prepare block was reloading the permitted attributes module. This resulted in the subscription parameters being appended to the spree premitted attributes multiple times. New behaviour: Do not auto load the lib directory Only load the permitted attributes once during the initalization process --- lib/solidus_subscriptions/engine.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/solidus_subscriptions/engine.rb') diff --git a/lib/solidus_subscriptions/engine.rb b/lib/solidus_subscriptions/engine.rb index baf4d9f..37c34e5 100644 --- a/lib/solidus_subscriptions/engine.rb +++ b/lib/solidus_subscriptions/engine.rb @@ -1,6 +1,9 @@ module SolidusSubscriptions class Engine < Rails::Engine require 'spree/core' + require 'solidus_subscriptions/permitted_attributes' + require 'solidus_subscriptions/config' + require 'solidus_subscriptions/processor' isolate_namespace SolidusSubscriptions engine_name 'solidus_subscriptions' @@ -11,10 +14,12 @@ module SolidusSubscriptions end config.autoload_paths << config.root.join('app', 'jobs') - config.autoload_paths << config.root.join('lib') - initializer 'solidus_subscriptions.configs', before: "spree.register.payment_methods" do - require 'solidus_subscriptions/config' + initializer 'configure spree subcription permitted attributes', after: 'require subscription lib helpers' do + PermittedAttributes.update_spree_permiteed_attributes + end + + initializer 'solidus_subscriptions.configs', before: "require subscription lib helpers" do end initializer 'register_subscription_promotion_rule', after: 'spree.promo.register.promotion.rules' do |app| @@ -39,7 +44,6 @@ module SolidusSubscriptions end Spree::Ability.register_ability(SolidusSubscriptions::Ability) - PermittedAttributes.update_spree_permiteed_attributes end config.to_prepare(&method(:activate).to_proc) -- cgit v1.2.3