Sha256: ede59bbd20675c4eb5d2ecd6e958e66fca59f350d07fca54c8e60179c4abddc8
Contents?: true
Size: 1014 Bytes
Versions: 43
Compression:
Stored size: 1014 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 if stale?(state) respond_with(@states) end 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]) return @country.states.accessible_by(current_ability, :read).order('name ASC') else return State.accessible_by(current_ability, :read).order('name ASC') end end end end end end
Version data entries
43 entries across 43 versions & 1 rubygems