Class: Spree::Api::V1::UsersController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#content_type, #permitted_line_item_attributes
included
Instance Method Details
#create ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/spree/api/v1/users_controller.rb', line 28
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
|
#destroy ⇒ Object
47
48
49
50
51
|
# File 'app/controllers/spree/api/v1/users_controller.rb', line 47
def destroy
authorize! :destroy, user
user.destroy
respond_with(user, status: 204)
end
|
#index ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/spree/api/v1/users_controller.rb', line 7
def index
@users = Spree.user_class.accessible_by(current_ability, :show)
@users = if params[:ids]
@users.ransack(id_in: params[:ids].split(','))
else
@users.ransack(params[:q])
end
@users = @users.result.page(params[:page]).per(params[:per_page])
expires_in 15.minutes, public: true
['Surrogate-Control'] = "max-age=#{15.minutes}"
respond_with(@users)
end
|
#new ⇒ Object
26
|
# File 'app/controllers/spree/api/v1/users_controller.rb', line 26
def new; end
|
#show ⇒ Object
22
23
24
|
# File 'app/controllers/spree/api/v1/users_controller.rb', line 22
def show
respond_with(user)
end
|
#update ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'app/controllers/spree/api/v1/users_controller.rb', line 38
def update
authorize! :update, user
if user.update(user_params)
respond_with(user, status: 200, default_template: :show)
else
invalid_resource!(user)
end
end
|