Class: Spree::Admin::UsersController
Instance Method Summary
collapse
belongs_to, #destroy, #edit, #new, #update_positions
#set_user_language_locale_key
Instance Method Details
#addresses ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/spree/admin/users_controller.rb', line 56
def addresses
if request.put?
if @user.update(user_params)
flash.now[:success] = t('spree.account_updated')
end
render :addresses
end
end
|
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/spree/admin/users_controller.rb', line 23
def create
@user = Spree.user_class.new(user_params)
if @user.save
set_roles
set_stock_locations
flash[:success] = t('spree.created_successfully')
redirect_to edit_admin_user_url(@user)
else
load_roles
load_stock_locations
flash.now[:error] = @user.errors.full_messages.join(", ")
render :new, status: :unprocessable_entity
end
end
|
#index ⇒ Object
13
14
15
16
17
|
# File 'app/controllers/spree/admin/users_controller.rb', line 13
def index
respond_with(@collection) do |format|
format.html
end
end
|
#items ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/controllers/spree/admin/users_controller.rb', line 72
def items
params[:q] ||= {}
@search = Spree::Order.includes(
line_items: {
variant: [:product, { option_values: :option_type }]
}
).ransack(params[:q].merge(user_id_eq: @user.id))
@orders = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
end
|
#model_class ⇒ Object
84
85
86
|
# File 'app/controllers/spree/admin/users_controller.rb', line 84
def model_class
Spree.user_class
end
|
#orders ⇒ Object
66
67
68
69
70
|
# File 'app/controllers/spree/admin/users_controller.rb', line 66
def orders
params[:q] ||= {}
@search = Spree::Order.reverse_chronological.ransack(params[:q].merge(user_id_eq: @user.id))
@orders = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
end
|
#show ⇒ Object
19
20
21
|
# File 'app/controllers/spree/admin/users_controller.rb', line 19
def show
redirect_to edit_admin_user_path(@user)
end
|
#update ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/spree/admin/users_controller.rb', line 40
def update
if @user.update(user_params)
set_roles
set_stock_locations
flash[:success] = t('spree.account_updated')
redirect_to edit_admin_user_url(@user)
else
load_roles
load_stock_locations
flash.now[:error] = @user.errors.full_messages.join(", ")
render :edit, status: :unprocessable_entity
end
end
|