Class: Comable::UsersController

Inherits:
ApplicationController show all
Includes:
PermittedAttributes
Defined in:
app/controllers/comable/users_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#set_view_path

Instance Method Details

#showObject



7
8
9
# File 'app/controllers/comable/users_controller.rb', line 7

def show
  @orders = current_comable_user.orders.page(params[:page]).per(Comable::Config.orders_per_page)
end

#update_addressesObject



11
12
13
14
15
16
17
18
19
# File 'app/controllers/comable/users_controller.rb', line 11

def update_addresses
  current_comable_user.attributes = user_params
  if current_comable_user.save
    flash.now[:notice] = Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
  end
  render :addresses
end

#user_paramsObject



21
22
23
24
25
26
27
# File 'app/controllers/comable/users_controller.rb', line 21

def user_params
  params.require(:user).permit(
    :bill_address_id,
    :ship_address_id,
    addresses_attributes: permitted_address_attributes
  )
end