Sha256: 7957b88bd012ba50e5e72d18b67bc6d94881810709c6da05ff09606bc0740857

Contents?: true

Size: 618 Bytes

Versions: 8

Compression:

Stored size: 618 Bytes

Contents

module Spree
  module Api
    module V2
      class StatesController < Spree::Api::V2::BaseController
        skip_before_action :authenticate_user

        def index
          render_collection states
        end

        def show
          render_instance states.find(params[:id])
        end

        private

        def states
          @states ||= begin
            if params[:country_id].present?
              Spree::Country.find(params[:country_id]).states.includes(:country)
            else
              Spree::State.includes(:country)
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
solidus_json_api-0.3.1 app/controllers/spree/api/v2/states_controller.rb
solidus_json_api-0.3.0 app/controllers/spree/api/v2/states_controller.rb
spree_api_v2-0.2.2 app/controllers/spree/api/v2/states_controller.rb
solidus_api_v2-0.2.2 app/controllers/spree/api/v2/states_controller.rb
solidus_api_v2-0.2.1 app/controllers/spree/api/v2/states_controller.rb
spree_api_v2-0.2.1 app/controllers/spree/api/v2/states_controller.rb
spree_api_v2-0.2.0 app/controllers/spree/api/v2/states_controller.rb
solidus_api_v2-0.2.0 app/controllers/spree/api/v2/states_controller.rb