Sha256: 716da6e00a7c7b7142c1ec1f56e1dd6a256b832058c80a9f99c5e514b1689e47
Contents?: true
Size: 945 Bytes
Versions: 61
Compression:
Stored size: 945 Bytes
Contents
module Spree module Api module V1 class StatesController < Spree::Api::BaseController skip_before_action :authenticate_user def index @states = scope.ransack(params[:q]).result.includes(:country) if params[:page] || params[:per_page] @states = @states.page(params[:page]).per(params[:per_page]) end state = @states.last respond_with(@states) if stale?(state) end def show @state = scope.find(params[:id]) respond_with(@state) end private def scope if params[:country_id] @country = Country.accessible_by(current_ability, :show).find(params[:country_id]) @country.states.accessible_by(current_ability).order('name ASC') else State.accessible_by(current_ability).order('name ASC') end end end end end end
Version data entries
61 entries across 61 versions & 1 rubygems
Version | Path |
---|---|
spree_api-4.0.0.beta | app/controllers/spree/api/v1/states_controller.rb |