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
|
2017-03-10 00:36:22 +05:30
|
|
|
@tab_select = params[:tab]
|
|
|
|
|
if @tab_select.present?
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js { render action: 'field_select' }
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
render :edit
|
|
|
|
|
end
|
2014-11-04 17:42:47 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# PATCH/PUT /users/1
|
|
|
|
|
def update
|
2017-03-10 00:36:22 +05:30
|
|
|
respond_to do |format|
|
|
|
|
|
if @user.update(user_params)
|
|
|
|
|
flash[:notice] = 'User was successfully updated.'
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}."
|
|
|
|
|
end
|
|
|
|
|
format.js
|
2014-11-04 17:42:47 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
# Only allow a trusted parameter "white list" through.
|
|
|
|
|
def user_params
|
2017-03-10 00:36:22 +05:30
|
|
|
params.require(:user).permit(:name, :biography, :nickname, :affiliation, :googleplus, :twitter, :gna, :gnu, :github, :gitlab, :website_url, :linkedin, :diaspora, :savannah)
|
2014-11-04 17:42:47 +01:00
|
|
|
end
|
|
|
|
|
end
|