Finally got all callbacks available to all action that need them

This commit is contained in:
Rob Harrington
2015-01-20 17:41:01 +11:00
parent 42d6695264
commit 6991e5e6b1
3 changed files with 13 additions and 10 deletions

View File

@@ -11,8 +11,19 @@ class BaseController < ApplicationController
include Spree::ProductsHelper
before_filter :check_order_cycle_expiry
def load_active_distributors
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
end
private
def set_order_cycles
@order_cycles = OrderCycle.with_distributor(@distributor).active
# And default to the only order cycle if there's only the one
if @order_cycles.count == 1
current_order(true).set_order_cycle! @order_cycles.first
end
end
end

View File

@@ -92,13 +92,4 @@ class EnterprisesController < BaseController
def clean_permalink
params[:permalink] = params[:permalink].parameterize
end
def set_order_cycles
@order_cycles = OrderCycle.with_distributor(@distributor).active
# And default to the only order cycle if there's only the one
if @order_cycles.count == 1
current_order(true).set_order_cycle! @order_cycles.first
end
end
end

View File

@@ -3,6 +3,7 @@ require 'open_food_network/scope_product_to_hub'
class ShopController < BaseController
layout "darkswarm"
before_filter :require_distributor_chosen
before_filter :set_order_cycles
def show
redirect_to main_app.enterprise_shop_path(current_distributor)