Sha256: e7c59f06714e9ab0620b10406064bcfc277a48d418ae5e2f1bc4a429745d3dfa

Contents?: true

Size: 1.22 KB

Versions: 30

Compression:

Stored size: 1.22 KB

Contents

module Spree
  module Api
    class UsersController < Spree::Api::BaseController

      def index
        @users = Spree.user_class.accessible_by(current_ability,:read).ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
        respond_with(@users)
      end

      def show
        respond_with(user)
      end

      def new
      end

      def create
        authorize! :create, Spree.user_class
        @user = Spree.user_class.new(user_params)
        if @user.save
          respond_with(@user, :status => 201, :default_template => :show)
        else
          invalid_resource!(@user)
        end
      end

      def update
        authorize! :update, user
        if user.update_attributes(user_params)
          respond_with(user, :status => 200, :default_template => :show)
        else
          invalid_resource!(user)
        end
      end

      def destroy
        authorize! :destroy, user
        user.destroy
        respond_with(user, :status => 204)
      end

      private

      def user
        @user ||= Spree.user_class.accessible_by(current_ability, :read).find(params[:id])
      end

      def user_params
        params.require(:user).permit(permitted_user_attributes)
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
spree_api-2.2.14 app/controllers/spree/api/users_controller.rb
spree_api-2.2.13 app/controllers/spree/api/users_controller.rb
spree_api-2.2.12 app/controllers/spree/api/users_controller.rb
spree_api-2.2.11 app/controllers/spree/api/users_controller.rb
spree_api-2.2.10 app/controllers/spree/api/users_controller.rb
spree_api-2.2.9 app/controllers/spree/api/users_controller.rb
spree_api-2.1.12 app/controllers/spree/api/users_controller.rb
spree_api-2.2.8 app/controllers/spree/api/users_controller.rb
spree_api-2.1.11 app/controllers/spree/api/users_controller.rb
spree_api-2.2.7 app/controllers/spree/api/users_controller.rb
spree_api-2.1.10 app/controllers/spree/api/users_controller.rb
spree_api-2.1.9 app/controllers/spree/api/users_controller.rb
spree_api-2.2.6 app/controllers/spree/api/users_controller.rb
spree_api-2.2.5 app/controllers/spree/api/users_controller.rb
spree_api-2.1.8 app/controllers/spree/api/users_controller.rb
spree_api-2.3.1 app/controllers/spree/api/users_controller.rb
spree_api-2.2.4 app/controllers/spree/api/users_controller.rb
spree_api-2.2.3 app/controllers/spree/api/users_controller.rb
spree_api-2.3.0 app/controllers/spree/api/users_controller.rb
spree_api-2.2.2 app/controllers/spree/api/users_controller.rb