Class: Sites::UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/cas/sites/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/cas/sites/users_controller.rb', line 14

def create
  @user = ::Cas::User.new(user_params)
  @user.roles = user_params[:roles]
  @user.site_ids = user_params[:site_ids]
  if @user.save
    redirect_to site_users_url(@site)
  else
    get_selected_sites
    render :new
  end
end

#editObject



26
27
28
29
# File 'app/controllers/cas/sites/users_controller.rb', line 26

def edit
  @user = ::Cas::User.find(params[:id])
  get_selected_sites
end

#indexObject



5
6
7
# File 'app/controllers/cas/sites/users_controller.rb', line 5

def index
  @users = @site.users.order('name ASC')
end

#newObject



9
10
11
12
# File 'app/controllers/cas/sites/users_controller.rb', line 9

def new
  @user = ::Cas::User.new
  get_selected_sites
end

#updateObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/cas/sites/users_controller.rb', line 31

def update
  @user = ::Cas::User.find(params[:id])
  success = nil
  @user.site_ids = user_params[:site_ids]
  if user_params[:password].blank? && user_params[:password_confirmation].blank?
    without_password = user_params.except(:password, :password_confirmation)
    success = @user.update_without_password(without_password)
  else
    success = @user.update_attributes(user_params)
  end

  if success
    redirect_to site_users_url(@site)
  else
    get_selected_sites
    render 'edit'
  end
end