2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-11-04 17:42:47 +01:00
|
|
|
class UsersController < ApplicationController
|
|
|
|
|
load_and_authorize_resource
|
|
|
|
|
|
|
|
|
|
# GET /users/1
|
|
|
|
|
def show
|
|
|
|
|
@events = @user.events.where(state: :confirmed)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET /users/1/edit
|
|
|
|
|
def edit
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# PATCH/PUT /users/1
|
|
|
|
|
def update
|
|
|
|
|
if @user.update(user_params)
|
|
|
|
|
redirect_to @user, notice: 'User was successfully updated.'
|
|
|
|
|
else
|
2017-04-03 18:34:37 +03:00
|
|
|
flash.now[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
|
2014-11-04 17:42:47 +01:00
|
|
|
render :edit
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
# Only allow a trusted parameter "white list" through.
|
|
|
|
|
def user_params
|
2015-10-28 18:05:15 +02:00
|
|
|
params.require(:user).permit(:name, :biography, :nickname, :affiliation)
|
2014-11-04 17:42:47 +01:00
|
|
|
end
|
|
|
|
|
end
|