Sha256: d60aa24dfb3d6bd8622ac5102e60bffb92da49954c5eba6b2597ae6c60bc37c7
Contents?: true
Size: 841 Bytes
Versions: 22
Compression:
Stored size: 841 Bytes
Contents
module Spree module Api class StatesController < Spree::Api::BaseController skip_before_action :authenticate_user def index @states = scope.ransack(params[:q]).result. includes(:country).order('name ASC') if params[:page] || params[:per_page] @states = paginate(@states) end respond_with(@states) end def show @state = scope.find(params[:id]) respond_with(@state) end private def scope if params[:country_id] @country = Spree::Country.accessible_by(current_ability, :read).find(params[:country_id]) return @country.states.accessible_by(current_ability, :read) else return Spree::State.accessible_by(current_ability, :read) end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems