Class: Spree::Api::UsersController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #permitted_line_item_attributes, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/spree/api/users_controller.rb', line 17
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
36
37
38
39
40
|
# File 'app/controllers/spree/api/users_controller.rb', line 36
def destroy
authorize! :destroy, user
user.destroy
respond_with(user, :status => 204)
end
|
#index ⇒ Object
5
6
7
8
|
# File 'app/controllers/spree/api/users_controller.rb', line 5
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
|
#new ⇒ Object
14
15
|
# File 'app/controllers/spree/api/users_controller.rb', line 14
def new
end
|
#show ⇒ Object
10
11
12
|
# File 'app/controllers/spree/api/users_controller.rb', line 10
def show
respond_with(user)
end
|
#update ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'app/controllers/spree/api/users_controller.rb', line 27
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
|