users before filter
This commit is contained in:
parent
cf40f25a3d
commit
047afa02d1
1 changed files with 6 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UsersController < ApplicationController
|
||||
before_action :load_user
|
||||
load_and_authorize_resource
|
||||
|
||||
# GET /users/1
|
||||
|
|
@ -28,4 +29,9 @@ class UsersController < ApplicationController
|
|||
params.require(:user).permit(:name, :biography, :nickname, :affiliation,
|
||||
:picture, :picture_cache)
|
||||
end
|
||||
|
||||
# Somewhat of a hack: users/current/edit
|
||||
def load_user
|
||||
@user ||= (params[:user_id] && params[:user_id] != 'current' && User.find(params[:user_id]) || current_user)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue