2014-11-06 15:25:27 +00:00
|
|
|
class UsersController < ApplicationController
|
2014-12-17 06:31:51 +00:00
|
|
|
load_and_authorize_resource only: [:destroy]
|
|
|
|
|
2014-11-06 15:25:27 +00:00
|
|
|
def show
|
2014-11-23 20:12:31 +00:00
|
|
|
@user = User.find(params[:id])
|
2014-11-09 21:53:39 +00:00
|
|
|
@orders = @user.orders.paginate(page: params[:page])
|
2014-11-06 15:25:27 +00:00
|
|
|
end
|
2014-11-06 17:30:53 +00:00
|
|
|
|
2014-11-23 20:12:31 +00:00
|
|
|
def index
|
2015-01-06 19:18:01 +00:00
|
|
|
@users = User.members
|
2014-11-23 20:12:31 +00:00
|
|
|
end
|
2014-12-09 21:32:54 +00:00
|
|
|
|
|
|
|
def destroy
|
|
|
|
User.find(params[:id]).destroy
|
|
|
|
flash[:success] = "Succesfully removed user"
|
|
|
|
redirect_to users_path
|
|
|
|
end
|
|
|
|
|
2014-12-10 13:18:56 +00:00
|
|
|
def dagschotel
|
|
|
|
user = User.find(params[:user_id])
|
|
|
|
user.dagschotel = Product.find(params[:product_id])
|
2014-12-17 06:31:51 +00:00
|
|
|
if user.save
|
|
|
|
flash[:success] = "Succesfully removed user"
|
|
|
|
else
|
|
|
|
flash[:error] = "Error updating dagschotel"
|
|
|
|
end
|
2014-12-10 13:18:56 +00:00
|
|
|
redirect_to edit_user_registration_path(user)
|
|
|
|
end
|
2014-11-06 15:25:27 +00:00
|
|
|
end
|