Sha256: 14f957359fa797ca10661c911cb7b57494620c3b6afded276758a10f9a0abb44

Contents?: true

Size: 659 Bytes

Versions: 28

Compression:

Stored size: 659 Bytes

Contents

module Spree
  module Admin
    class StockLocationsController < ResourceController

      before_filter :set_country, :only => :new

      private

      def set_country
        begin
          if Spree::Config[:default_country_id].present?
            @stock_location.country = Spree::Country.find(Spree::Config[:default_country_id])
          else
            @stock_location.country = Spree::Country.find_by!(iso: 'US')
          end

        rescue ActiveRecord::RecordNotFound
          flash[:error] = Spree.t(:stock_locations_need_a_default_country)
          redirect_to admin_stock_locations_path and return
        end
      end

    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
spree_backend-2.3.2 app/controllers/spree/admin/stock_locations_controller.rb
spree_backend-2.2.5 app/controllers/spree/admin/stock_locations_controller.rb
spree_backend-2.3.1 app/controllers/spree/admin/stock_locations_controller.rb
spree_backend-2.2.4 app/controllers/spree/admin/stock_locations_controller.rb
spree_backend-2.2.3 app/controllers/spree/admin/stock_locations_controller.rb
spree_backend-2.3.0 app/controllers/spree/admin/stock_locations_controller.rb
spree_backend-2.2.2 app/controllers/spree/admin/stock_locations_controller.rb
spree_backend-2.2.1 app/controllers/spree/admin/stock_locations_controller.rb