Class: SolidusAdmin::UsersController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- SolidusAdmin::UsersController
- Includes:
- ControllerHelpers::Search, Spree::Core::ControllerHelpers::StrongParameters
- Defined in:
- app/controllers/solidus_admin/users_controller.rb
Instance Method Summary collapse
- #addresses ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #items ⇒ Object
- #orders ⇒ Object
- #store_credits ⇒ Object
- #update_addresses ⇒ Object
Methods included from ComponentsHelper
Instance Method Details
#addresses ⇒ Object
29 30 31 32 33 34 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 29 def addresses respond_to do |format| format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' } format.html { render component('users/addresses').new(user: @user) } end end |
#destroy ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 75 def destroy @users = Spree.user_class.where(id: params[:id]) Spree.user_class.transaction { @users.destroy_all } flash[:notice] = t('.success') redirect_back_or_to users_path, status: :see_other end |
#edit ⇒ Object
69 70 71 72 73 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 69 def edit respond_to do |format| format.html { render component('users/edit').new(user: @user) } end end |
#index ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 16 def index users = apply_search_to( Spree.user_class.order(created_at: :desc, id: :desc), param: :q, ) set_page_and_extract_portion_from(users) respond_to do |format| format.html { render component('users/index').new(page: @page) } end end |
#items ⇒ Object
61 62 63 64 65 66 67 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 61 def items set_items respond_to do |format| format.html { render component('users/items').new(user: @user, items: @items) } end end |
#orders ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 53 def orders set_orders respond_to do |format| format.html { render component('users/orders').new(user: @user, orders: @orders) } end end |
#store_credits ⇒ Object
84 85 86 87 88 89 90 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 84 def store_credits @store_credits = Spree::StoreCredit.where(user_id: @user.id).order(id: :desc) respond_to do |format| format.html { render component("users/store_credits/index").new(user: @user, store_credits: @store_credits) } end end |
#update_addresses ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/solidus_admin/users_controller.rb', line 36 def update_addresses set_address_from_params if @address.valid? && @user.update(user_params) flash[:success] = t(".#{@type}.success") respond_to do |format| format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' } format.html { render component('users/addresses').new(user: @user) } end else respond_to do |format| format.html { render component('users/addresses').new(user: @user, address: @address, type: @type), status: :unprocessable_entity } end end end |