osem-fcy/app/controllers/users_controller.rb
Michael Ball 3883188dcd Support Users Directly Uploading Profile Pictures.
* Adds a `picture` attribute to `User`.
* Preserves Gravatar as a fallback option.
* Now, you should use `user.profile_picturer` instead of `gravatar_url`
* TODO: Ensure `profile_picture` handles sizing right for uploaded images.
2020-07-14 21:06:15 -07:00

31 lines
710 B
Ruby

# frozen_string_literal: true
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
flash.now[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
render :edit
end
end
private
def user_params
params.require(:user).permit(:name, :biography, :nickname, :affiliation,
:picture, :picture_cache)
end
end