Class: Spree::Api::V1::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v1/users_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#content_type, #map_nested_attributes_keys, #permitted_line_item_attributes

Methods included from ControllerSetup

included

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/spree/api/v1/users_controller.rb', line 20

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

#destroyObject



39
40
41
42
43
# File 'app/controllers/spree/api/v1/users_controller.rb', line 39

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

#indexObject



8
9
10
11
# File 'app/controllers/spree/api/v1/users_controller.rb', line 8

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

#newObject



17
18
# File 'app/controllers/spree/api/v1/users_controller.rb', line 17

def new
end

#showObject



13
14
15
# File 'app/controllers/spree/api/v1/users_controller.rb', line 13

def show
  respond_with(user)
end

#updateObject



30
31
32
33
34
35
36
37
# File 'app/controllers/spree/api/v1/users_controller.rb', line 30

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