Class: Profiles

Inherits:
UsersApp
  • Object
show all
Defined in:
app/controllers/profiles.rb

Instance Method Summary collapse

Instance Method Details

#add_roleObject



40
41
42
43
44
45
46
47
48
# File 'app/controllers/profiles.rb', line 40

def add_role
  require_permission "add_#{params[:role]}_role"

  @user.add_role params[:role]
  @user.save!
  @user.reload
  flash[:info] = t :role_granted
  render action: :update
end

#allObject



17
18
19
# File 'app/controllers/profiles.rb', line 17

def all
  @users = Models::User.all
end

#editObject



26
27
# File 'app/controllers/profiles.rb', line 26

def edit
end

#remove_roleObject



50
51
52
53
54
55
56
57
58
# File 'app/controllers/profiles.rb', line 50

def remove_role
  require_permission "remove_#{params[:role]}_role"

  @user.remove_role params[:role]
  @user.save!
  @user.reload
  flash[:info] = t :role_removed
  render action: :update
end

#showObject



21
22
# File 'app/controllers/profiles.rb', line 21

def show
end

#updateObject



29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/profiles.rb', line 29

def update
  access_denied if @user.anonymous? and !Models::User.current.admin?

  if @user.update_attributes params[:user]
    flash[:info] = t :user_updated
    # redirect_to action: :show
  else
    render action: :edit
  end
end