Sha256: ef104ee48405525f09f9326951d9da9f10ae4fc669de542d62a747d387c3dc6e
Contents?: true
Size: 964 Bytes
Versions: 2
Compression:
Stored size: 964 Bytes
Contents
module Spree module Api class StatesController < Spree::Api::BaseController skip_before_action :set_expiry skip_before_action :check_for_user_or_api_key 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 = @states.page(params[:page]).per(params[:per_page]) end respond_with(@states) 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) else return State.accessible_by(current_ability, :read) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_api-1.0.0.pre2 | app/controllers/spree/api/states_controller.rb |
solidus_api-1.0.0.pre | app/controllers/spree/api/states_controller.rb |