Sha256: 3102ce5647d43cb268f0140ad55e60fd8505c8709c8c6b4b40b76f4d158e144b
Contents?: true
Size: 959 Bytes
Versions: 39
Compression:
Stored size: 959 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, :read).find(params[:country_id]) @country.states.accessible_by(current_ability, :read).order('name ASC') else State.accessible_by(current_ability, :read).order('name ASC') end end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems